I am writing an ItemUpdating event receiver for a document library in MOSS 2007 (yes, I am still on that version!) and need to bake in some validation. If the validation fails or if an exception is thrown anywhere in that method, SharePoint typically takes me to a less-than-stellar error page. I wish to take a user-friendlier approach, seeking to redirect the user back to the EditForm.aspx page, displaying the form with the submitted values and one or more error message(s) right above the form. How do I achieve this, without involving SharePoint Designer? This needs to be a pure Visual Studio based solution.


Since I haven't seen MOSS 2007 for a while, I'm not sure if this will work:

properties.ErrorMessage = <ERROR MESSAGE>;
properties.Status = SPEventReceiverStatus.CanceWithRedirectUrl;
properties.RedirectUrl = <YOUR URL WITH QUERY STRING>;
|improve this answer|||||
  • I have come across this option, but I am not sure it will take me back to the EditForm.aspx page and display all the values submitted by the user, intact. Will it? – Web User Oct 5 '15 at 11:31
  • The RedirectUrl property is not in WSS 3 apparently. Without that line, it takes me to an user unfriendly error page displaying the error, but also the stack trace. – Web User Dec 16 '15 at 8:55

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.