VB.NET
Private Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Error
Response.Write(Server.GetLastError().ToString)
Server.ClearError()
End Sub
C#
//In InitializeComponent
this.Error += new System.EventHandler (this.Page_Error );
//
private void Page_Error(object sender, System.EventArgs e )
{
Response.Write(Server.GetLastError().ToString());
Server.ClearError ();
}
In the Same manner handle the Errors in the Application_Error event in global.asax
Share with