Page level error (C#) : Page Error « Page « ASP.Net






Page level error (C#)

<script Language="c#" runat="server">
  void PageLevelErrorTest()
  {
    // Remove opening try
    int[] array = new int[9];
    for(int intCounter=0; intCounter <= 9;intCounter++)
    {
       array[intCounter] = intCounter;
       Response.Write("The value of the counter is:" + intCounter + "<br>");
    }
    // Remove catch and finally blocks
  }
  void Page_Error(object sender, EventArgs e)
  {
    Response.Write("Error occurred: " + Server.GetLastError().ToString());
    Server.ClearError();
  }
  void Page_Load()
  {
    PageLevelErrorTest();
  }
</script>
<%
  Response.Write("Function call completed" + "<br>");
%>

           
       








Related examples in the same category

1.Page.ErrorPage property (VB.net)
2.Page_Error() method (VB.net)