ASP.net Popup on Exception

Capodecina
Permabanned
Joined
31 Dec 2003
Posts
5,172
Location
Barrow-In-Furness
Hey guys, i'm trying to handle an exception and display a poup message to prompt the user to show that they could not delete a GridView row. I've used very similar code on a different page and it works, but it isn't on here and I can't figure out why..

It doesn't crash to the error message and the row is not deleted (it can't be due to relationship constrains), but it does not display the popup error like I want. Anyways, here's the code



Code:
Protected Sub CodesGridView_RowDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeletedEventArgs) Handles CodesGridView.RowDeleted
        If e.Exception IsNot Nothing Then
            If e.AffectedRows = 0 Then
                Dim S As String = e.Exception.InnerException.Message.ToString
                If S.Substring(0, 48) = "DELETE statement conflicted with COLUMN REFERENCE" Then
                    S = "This Timecode has hours logged to it, unable to delete"
                End If
                Dim MyScript As String = "alert('" & S & "');"
                Page.ClientScript.RegisterStartupScript(Me.GetType(), "myKey", MyScript, True)
            End If

            e.ExceptionHandled = True

        End If
    End Sub
 
Back
Top Bottom