Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

thanks,

KS

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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