Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sune Jepsen 25 posts 109 karma points
    Mar 01, 2011 @ 20:50
    Sune Jepsen
    0

    Capture Events

    Im using umbraco v 4.5.2 and I want to capture the event afterDelete, my code looks like:


    public class PageDeleteEvents : ApplicationBase
    {
        private Entitycontext db = new Entitycontext ();
        public PageDeleteEvents ()
        {
            Document.AfterDelete += new Document.DeleteEventHandler(Document_AfterDelete);
            Document.BeforeDelete += new Document.DeleteEventHandler(Document_BeforeDelete);

        }

      

        void Document_BeforeDelete(Document sender, umbraco.cms.businesslogic.DeleteEventArgs e)
        {


            throw new Exception(Convert.ToInt32(sender.getProperty("itemID").Value).ToString());


        }

        void Document_AfterDelete(Document sender, umbraco.cms.businesslogic.DeleteEventArgs e)
        {
            throw new Exception(Convert.ToInt32(sender.getProperty("itemID").Value).ToString());




        }

    .....

    But my problem is that my code doesent get executed, ive tried with beforesave and beforepublish and they are working but the delete events doesent. Any idea why?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 01, 2011 @ 21:46
    Tom Fulton
    0

    Hi,

    I think the Delete events are only fired after deleting from/emptying the recycle bin.  I think there are some Document.BeforeMoveToTrash and Document.AfterMoveToTrash depending on your situation

    Thanks,
    Tom

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies