Pages

Subscribe:

Thursday, December 1, 2011

Custom Error Page

With 2007, you can cancel events and return an error message to the user, but that provides limited interactivity  and not much help to the user beyond what your error message says. With 2010 events, you can cancel the event on your synchronous events and redirect the user to a custom error page that you create. The custom error pages and redirection will only work for pre-synchronous events,so you cannot do this for post-synchronous events such as ListAdded.


The way to implement custom error pages is to set the status property on your property bag for your event receiver to SPEventReceiverStatus.CancelWithRedirectedUrl, set the RedirectUrl property to a relative URL for your error page, and set the cancel property to true.


      properties.Cancel = true;
      properties.Status = SPEventReceiverStatus.CancelWithRedirectedUrl;
      properties.RedirectUrl = "/_layouts/mycustomerror.aspx";

No comments:

Post a Comment