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);
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?
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
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?
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
is working on a reply...