VB.NET - Dynamic Exceptions Handling with the Message Box



Handling exceptions dynamically with message

      Try
        Catch ex As Exception
            MessageBox("Error:  " & ex.Message.ToString() & "  :: " & _
                        ex.StackTrace())
        End Try

Code to display Message Box


    Private Sub MessageBox(ByVal msg As String)
           Dim lbl As New Label()
        ' add the javascript to fire an alertbox to the label and
        ' add the string argument passed to the subroutine as the
        ' message payload for the alertbox
        lbl.Text = "<script language='javascript'>" & Environment.NewLine & _
                   "window.alert('" + msg + "')</script>"

        ' add the label to the page to display the alertbox
        Page.Controls.Add(lbl)
    End Sub

Share |

 Cant find the page you are looking for?
 Help us to improve by adding the content that you are looking for.
 Leave a feedback
 We look forward to hear your comments and feedback.