Is there a way to show error notification to user when error occurred during partial postback of an Update Panel?
I have tried injecting script using RegisterStartupScript
and RegisterClientScriptBlock
both, but failed, I believe because partial postback is not successful therefore update panel's internal framework stop executing script, which causes my error notification script to not run. Below is the error I generated on click of a Test button, on click of which
Below is the code I'm using to inject error notification alert box for all errors caused during partial postback.
protected void Application_Error(object sender, EventArgs e) {
Entities.Exception exceptionObj = new Entities.Exception();
Exception x = Server.GetLastError();
if (x != null) {
if (x.InnerException != null) {
exceptionObj.Message = x.InnerException.Message.ToString();
exceptionObj.StackTrace = x.InnerException.ToString();
} else {
exceptionObj.Message = x.Message.ToString();
exceptionObj.StackTrace = x.ToString();
}
}
Server.ClearError();
System.Web.UI.Page page = System.Web.HttpContext.Current.Handler as System.Web.UI.Page;
if (page != null) {
RadAjaxManager MainRadAjaxManager = RadAjaxManager.GetCurrent(page);
if (MainRadAjaxManager != null && MainRadAjaxManager.IsAjaxRequest)
// didn't work
//MainRadAjaxManager.ResponseScripts.Add(script);
// didn't work
//page.ClientScript.RegisterStartupScript(page.GetType(), Guid.NewGuid().ToString(), "alert('Yogesh');", true);
// didn't work
page.ClientScript.RegisterClientScriptBlock(page.GetType(), Guid.NewGuid().ToString(), "alert('Error Occured.');", true);
}
}
Note: I'm using Telerik's RadAjaxManager