System.Windows.Forms.HtmlElement.AttachEventHandler Method

Adds an event handler for a named event on the HTML Document Object Model (DOM).

Syntax

public void AttachEventHandler (string eventName, EventHandler eventHandler)

Parameters

eventName
The name of the event you want to handle.
eventHandler
The managed code that handles the event.

Remarks

The Managed Document Object Model (DOM) exposes only a select number of events. Most of the unexposed events are only defined for specific types of elements; such as the submit event, which is valid only on FORM elements. Use HtmlElement.AttachEventHandler(string, EventHandler) to add an event handler to these unexposed events.

You should not attach an event to the document or one of its objects until the document has completed loading. The earliest you should call this method is in the WebBrowser.DocumentCompleted event of the System.Windows.Forms.WebBrowser control.

For more information about the available unmanaged events, see Accessing Unexposed Members on the Managed HTML Document Object Model and the IHTMLElement interfaces: tp://go.microsoft.com/fwlink/?LinkId=104876, tp://go.microsoft.com/fwlink/?LinkId=104877, tp://go.microsoft.com/fwlink/?LinkId=104878, tp://go.microsoft.com/fwlink/?LinkId=104879.

Requirements

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