jleone
05-01-2009, 04:25 PM
I'm building an AJAX app and need to handle my server side errors. I have everything in place based on how an MSDN page example shows, but modified of course to suit my process.
Try
Throw New Exception("Testing error code.")
If Session("Selection") IsNot Nothing Then
Selection = Session("Selection")
Else
Selection = New Selection()
End If
Selection.GetSummaryData()
Me.ClntSummGridView.DataSource = Selection.ClientSummaryData
Me.ClntSummGridView.DataBind()
Catch ex As Exception
Throw ex
End Try
Protected Sub ScriptManager1_AsyncPostBackError(ByVal sender As Object, ByVal e As System.Web.UI.AsyncPostBackErrorEventArgs) ScriptManager1.AsyncPostBackErrorMessage = e.Exception.Message
End Sub
This is exactly how the MSDN shows to do it but when my code runs in Visual Studio it says I have an unhandled error in code due to the "Throw ex", but when I hit the play button it continues on and shows my exception error in an alert box, as my Javascript code is set up to do.
Now, I have tried to set the "ScriptManager1.AsyncPostBackErrorMessage" directly within my "catch" block and removed the ScriptManager1_AsyncPostBackError sub altogether and then the Javascript code reports no error. What is the deal with this?
Try
Throw New Exception("Testing error code.")
If Session("Selection") IsNot Nothing Then
Selection = Session("Selection")
Else
Selection = New Selection()
End If
Selection.GetSummaryData()
Me.ClntSummGridView.DataSource = Selection.ClientSummaryData
Me.ClntSummGridView.DataBind()
Catch ex As Exception
Throw ex
End Try
Protected Sub ScriptManager1_AsyncPostBackError(ByVal sender As Object, ByVal e As System.Web.UI.AsyncPostBackErrorEventArgs) ScriptManager1.AsyncPostBackErrorMessage = e.Exception.Message
End Sub
This is exactly how the MSDN shows to do it but when my code runs in Visual Studio it says I have an unhandled error in code due to the "Throw ex", but when I hit the play button it continues on and shows my exception error in an alert box, as my Javascript code is set up to do.
Now, I have tried to set the "ScriptManager1.AsyncPostBackErrorMessage" directly within my "catch" block and removed the ScriptManager1_AsyncPostBackError sub altogether and then the Javascript code reports no error. What is the deal with this?