Feb 10, 2012, 6:06 AM
JavaScript does not work in Request Failure window
Hi all,
In my web application, I want to handle Ext.Net Ajax exceptions that occurs when request to server and show friendly error message.
I wrote some JavaScript codes in my error message HTML to do some actions in the code bellow.
When clicking on the Detail link on the shown error message window to get more details of the error message, but the JavaScript does not act anything.
Do you know what's reason here and could you please give me an advice?
Thanks so much.
In my web application, I want to handle Ext.Net Ajax exceptions that occurs when request to server and show friendly error message.
I wrote some JavaScript codes in my error message HTML to do some actions in the code bellow.
When clicking on the Detail link on the shown error message window to get more details of the error message, but the JavaScript does not act anything.
Do you know what's reason here and could you please give me an advice?
Thanks so much.
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim curError As System.Exception = HttpContext.Current.Error
Response.Clear()
Response.ClearHeaders()
Response.StatusCode = 500
Response.Write(GetErrorMessage(curError))
Response.End()
End Sub
Private Function GetErrorMessage(ByVal e As Exception) As String
Dim strHTML As New StringBuilder()
strHTML.AppendLine("<html>")
strHTML.AppendLine("<head>")
strHTML.AppendLine("<title>")
strHTML.AppendLine("</title>")
strHTML.AppendLine("<script type='text/javascript'>")
strHTML.AppendLine("function viewDetail(){")
strHTML.AppendLine("var pnlDetail = document.getElementById('pnlDetail');")
strHTML.AppendLine("if (pnlDetail.style.visibility == 'visible') {")
strHTML.AppendLine(" pnlDetail.style.visibility = 'hidden';")
strHTML.AppendLine(" else {")
strHTML.AppendLine(" pnlDetail.style.visibility = 'visible';")
strHTML.AppendLine("}}")
strHTML.AppendLine("</script>")
strHTML.AppendLine("</head>")
strHTML.AppendLine("<body>")
strHTML.AppendLine("<b>An error occured! </b>")
strHTML.AppendLine("<br>")
strHTML.AppendLine("<a onclick='viewDetail();'>Detail</a>")
strHTML.AppendLine("<div id='pnlDetail' style='visibility:hidden'>")
strHTML.AppendLine("Error Message Detail")
strHTML.AppendLine("</div>")
strHTML.AppendLine("</body>")
strHTML.AppendLine("</html>")
Return strHTML.ToString()
End Function
Last edited by sonnh11; Feb 10, 2012 at 6:29 AM.