Редагувати

Поділитися через


HtmlElementErrorEventArgs.Handled Property

Definition

Gets or sets whether this error has been handled by the application hosting the document.

public:
 property bool Handled { bool get(); void set(bool value); };
public bool Handled { get; set; }
member this.Handled : bool with get, set
Public Property Handled As Boolean

Property Value

true if the event has been handled; otherwise, false. The default is false.

Examples

The following code example demonstrates how to suppress a script error and display your own custom dialog box. This code example requires that your application host a WebBrowser control named webBrowser1.

private void SuppressScriptErrors()
{
    if (webBrowser1.Document != null)
    {
        webBrowser1.Document.Window.Error += new HtmlElementErrorEventHandler(scriptWindow_Error);
    }
}

private void  scriptWindow_Error(object sender, HtmlElementErrorEventArgs e)
{
    MessageBox.Show("Suppressed error!");
    e.Handled = true;
}
Dim WithEvents ScriptWindow As HtmlWindow

Private Sub SuppressScriptErrors()
    If (WebBrowser1.Document IsNot Nothing) Then
        ScriptWindow = WebBrowser1.Document.Window
    End If
End Sub

Private Sub ScriptWindow_Error(ByVal sender As Object, ByVal e As HtmlElementErrorEventArgs) Handles ScriptWindow.Error
    MessageBox.Show("Suppressed error!")
    e.Handled = True
End Sub

Remarks

Set this property to true if you wish to display your own custom error message to the user, or suppress the error entirely.

Applies to