Item gets deleted before OnItemDeleting

Topics: Developer Forum, Project Management Forum, User Forum
Nov 14, 2008 at 9:03 PM
I have added an event handler to the OnItemDeleting.

In it, I would like to make references to the parent determining if the item is allowed to be deleted.

The handler wasn't doing as expected so when I took a peak at the e.AffectedItem.Parent, it was the trash container.

The parent was "Start Page" when I deleted it but by the time it gets to the event handler, it is the trash container.

The weird thing is that when I attach a break point to the OnDeleteButtonClick in the edit/delete.aspx, I see the SelectedItem (the one being deleted and the parent is startpage). Now when the invoking of the event handlers happens, the parent becomes trash container.

The code that actually does the deleting of the item is after the invoking in the click event. Why would the parent change?
Nov 15, 2008 at 6:01 PM
The trashcan functionality uses the same event you're using but it's invoked before you get a chance to do anything. Perhaps there should be a way to defer the actual movement to the bin until other handlers have had a chance to do theirs.