SharePoint 2010 Workaround: How to revert back to the Original Form after landing on SharePoint Custom Error Page

With SharePoint 2010 , while cancelling an event (off course synchronous events end with ing ), you can also redirect users to your custom error page. This is quite helpful , but there is a small glitch. Once you are landed on the custom error page, there is no out of the box way to go back to the original form. This is important as you may want to go back to the original form in case you want to fix some data entries etc. One of the obvious reason that this is not provided is because as custom error pages are essentially SharePoint Application pages , the implementation is left on your side. Having said that , you still need some way out of this. Following is a quick workaround for this. I am assuming that you already have event receiver and a blank custom error page.If not its super easy to do so using Visual Studio 2010 and creating SharePoint 2010 Project of type Event Handler (I don’t show the steps to create the project  here to make this post short and topic specific)

The project look like this . off course project name and custom error page will be different but that is not relevant) 


In the application page (which will be used as a custom error page) I just added a single line inside Main content , as shown below.


For the event receiver , I have implemented  ItemAdding  event receiver for a custom list . The event is cancelled with redirection to a custom error page , this is shown in the code fragment below.You may want to adjust the folder and error page name accordingly.


At this point , if you deploy  the project (F5 from Visual Studio 2010 would do) and then try to add a new item to the custom list ,  you will see the custom error page as shown below.



Now , lets address this issue of not going back to the original form. Add the following mark-up inside the custom error (application page).


Now re-deploy the solution (F5 from Visual Studio would do) again, and try to add  new item into the custom list. This time you will see the custom error page with two links , namely “Go back to previous page” and other “Close” , this is shown in figure below.


Clicking “Close” link will close the dialog , while “Go back to previous page” link will revert back to previous page as shown below.


NOTE: Although this workaround works most of the time, do test it extensively before using it. Also , note  that this post was based on SharePoint 2010 Beta , its most likely that the workaround will work in RTM but still there is no guarantee. 


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s