Exceptions that occur during Ajax postback are presented as a JavaScript alert, the goal is to hook up on EngRequest event so that you can access EndRequestEventArgs class that provides an information about exceptions occurred. That way you can eliminate JavaScript alert and show useful information in custom message boxes like those I show you in my previous articles CSS Message Boxes and MessageBox user control using ASP.NET and CSS.
However, if you want to be able to do some server processing when error occur you can make use of ScriptManager. You will have to define OnAsyncPostBackError handler in the definition of ScriptManager.
<asp:ScriptManager ID="ScriptManager1" runat="server" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError" />
This will allow you to have the access to the error on the server:
protected void ScriptManager1_AsyncPostBackError(object sender,AsyncPostBackErrorEventArgs e)
{
// do whatever you need to do here
}
No comments:
Post a Comment