In some requirement the exception needs to be displayed in page view-source, so the below code will explain how to make it easily,
Code Sample:
try
Code Sample:
try
{
//Error Occured
SPSite _Site = new SPSite("Site URL");
}
catch (Exception
ex)
{
//Catching the Exception
System.Web.UI.HtmlControls.HtmlGenericControl
dynDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
dynDiv.ID = "dynDivCode";
dynDiv.InnerHtml = "\n<!--EVL
Exception BeginTag-->\n<!--"+ex.Message+"-->\n<!--EVL Exception EndTag-->\n";
this.Controls.Add(dynDiv);
}
No comments:
Post a Comment