Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
ASP.NET Reference
Client Reference
Sys.UI Namespace
 addHandlers Method

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Sys.UI.DomEvent addHandlers Method

Adds a list of DOM event handlers to the DOM element that exposes the events. This member is static and can be invoked without creating an instance of the class.

Sys.UI.DomEvent.addHandlers(element, events, handlerOwner);

Term

Definition

element

The DOM element that exposes the events.

events

A dictionary of event handlers.

handlerOwner

(Optional) The object instance that is the context for the delegates that should be created from the handlers.

Exception type

Condition

Error.invalidOperation

(Debug) One of the handlers specified in events is not a function.

Use the addHandlers method to add a list of DOM event handlers to the element that exposes the event.

The events parameter takes a comma-separated list of name/value pairs in the format name:value, where name is the name of the DOM event and value is the name of the handler function. If there is more than one name/value pair, the list must be enclosed in braces ({}) to identify it as a single parameter. Multiple name/value pairs are separated with commas. Event names should not include the "on" prefix. For example, specify "click" instead of "onclick".

If handlerOwner is specified, delegates are created for each handler. These delegates are attached to the specified object instance, and the this pointer from the delegate handler will refer to the handlerOwner object.

This method can be accessed through the $addHandlers shortcut method.

The following example shows how to associate event handlers with an element by using the addHandlers method.

Visual Basic
<script type="text/javascript">
    Sys.UI.DomEvent.addHandlers($get("Button1"), {click:processEventInfo,mouseover:processEventInfo,mouseout:processEventInfo});

    function processEventInfo(eventElement) {
        var result = '';
        result += eventElement.type;
        $get('Label2').innerHTML = result;
    }
 </script>

C#
<script type="text/javascript">
    Sys.UI.DomEvent.addHandlers($get("Button1"), {click:processEventInfo,mouseover:processEventInfo,mouseout:processEventInfo});

    function processEventInfo(eventElement) {
        var result = '';
        result += eventElement.type;
        $get('Label2').innerHTML = result;
    }
 </script>

Reference

Other Resources

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker