Friday, October 3, 2008

Easy way to Redirect Users to an Error Page and Success page in SharePoint

While developing custom application Pages and web parts we mostly come across
the scenario for redirecting user to Some Error Page or Redirecting user to some
default page after successful operation.
WSS 3.0 provides a very easy and consistent way to provide this.
Just a single line of code; Below here is the sample code
 1. TransferToSuccessPage :
  SPUtility.TransferToSuccessPage("Operation was completed",
@"/Docs/default.aspx", "", "");




2 . TransferToErrorPage :

try
{
//Code that might cause an exception
}
catch (Exception ex)
{
SPUtility.TransferToErrorPage(ex.Message);
}

No comments: