Scenario: Adding a document to document library, then copying it to another doc lib and then deleting it using the ItemUpdated event receiver.

Problem: The popup window (EditForm.aspx) usually closes after you submit the fields (when you add an item OOTB).

However, for my scenario after the delete takes place, the page is redirecting to the actual item that was deleted.

Is there any way to stop this behaviour?




The redirect takes place after the ItemUpdating event and is completely independent of the ItemUpdated event. The ItemUpdated event just takes place at an arbitrary time after ItemUpdating has succeeded.

That being said, at the end of ItemUpdating you could do a Response.Redirect (or your redirect method of choice - SPUtilities has an option for you) AFTER you know every other bit of ItemUpdating is going to succeed (this most likely includes base.ItemUpdating)

What you cannot do, is redirect based off of something that happened in ItemUpdated. So if you wanted to redirect somewhere else ONLY if you were deleting in ItemUpdated, you would not be able to do this unless the data to make that determination was already available to you in ItemUpdating.

  • Thanks thats helpfull - although I assume that I can ensure ItemUpdated definetly occurs after ItemUpdating by setting it to Synchronous? However, the problem is my document library is sitting on a page as a web part, there is no way of me getting hold of the url as there is no SPContext. – Perplexed Jun 11 '12 at 20:25
  • Well thats just how the events work. Updating happens while its being updated. You can cancel out of the update due to errors here. Updated happens AFTER all Updating has been completed - just like the English words mean! Is the web part custom? Why are you doing it in events instead of form logic? Either way, you could create a configuration list or use the property bag to store the redirect URL and look it up when you need it. If it ever changes you just change the value in the list / property bag. – SpartanDonut Jun 12 '12 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.