HtmlElementErrorEventArgs.Handled 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置承载文档的应用程序是否已处理此错误。
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
属性值
true 如果已处理事件,则为否则,为 false. 默认值为 false。
示例
下面的代码示例演示如何取消脚本错误并显示自己的自定义对话框。 此代码示例要求应用程序托管名为
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
注解
如果要向用户显示自己的自定义错误消息,或完全禁止显示该错误,请将此属性设置为 true 该属性。