Search This Blog

Sunday, June 19, 2016

Custom Error page in Event Receivers for SharePoint 2013

Following steps for Custom Error Page.


1. Update the Event Receiver: ItemAdding Section's Code would be:

public override void ItemAdding(SPItemEventProperties properties)
       {
          base.ItemAdding(properties);

           if (!properties.AfterUrl.EndsWith("pdf"))
           {
               properties.Status=SPEventReceiverStatus.CancelWithRedirectUrl;
               properties.RedirectUrl = "/_Layouts/ERTest/ApplicationPage1.aspx";
           }
       }
2. Add a Application Page to the Project, optionally a Icon to represent Error.


3. Update the Error page: Under the PlaceHolderMain Place some content to give descriptive Error message:


See the Result in action: SharePoint 2010 event receiver custom error page.



No comments:

Post a Comment