HtmlElementErrorEventArgs.Handled Właściwość

Definicja

Pobiera lub ustawia, czy ten błąd został obsłużony przez aplikację hostująca dokument.

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

Wartość właściwości

true jeśli zdarzenie zostało obsłużone; w przeciwnym razie , false. Wartość domyślna to false.

Przykłady

Poniższy przykład kodu pokazuje, jak pominąć błąd skryptu i wyświetlić własne niestandardowe okno dialogowe. Ten przykład kodu wymaga, aby aplikacja hostować kontrolkę WebBrowser o nazwie 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

Uwagi

Ustaw tę właściwość na true wartość , jeśli chcesz wyświetlić użytkownikowi własny niestandardowy komunikat o błędzie lub całkowicie pominąć błąd.

Dotyczy