Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HtmlWindow.Error Event

Occurs when script running inside of the window encounters a run-time error.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member Error : IEvent<HtmlElementErrorEventHandler,
    HtmlElementErrorEventArgs>

HTML pages can contain script code, usually written in JScript or VBScript, that executes when a page is loaded. Error occurs whenever a script encounters a run-time error. Because script code is late-bound, which means that calls against the object are not resolved until run-time, errors can include everything from referencing a null object to calling an undefined property or method.

You can set the Handled property of HtmlElementErrorEventArgs to true in order to prevent the native error dialog box in Internet Explorer from displaying.

For more information about the difference between canceling event bubbling and canceling the default action on an event, see About the DHTML Object Model.

The following code example traps the error that results when a script on an HTML page attempts to access an object that is not defined in the document. The page must be fully loaded before the Error event handler is attached, otherwise the example will not work.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft