Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Sys.EventHandlerList.removeHandler Method

Removes an event handler from an event in an EventHandlerList instance.

Syntax

var e = new EventHandlerList();
e.addHandler(id, handler);
e.removeHandler(id, handler);

Arguments

id

The ID for the event.

handler

The handler to remove from the event.

Remarks

Use the removeHandler method to remove an event handler from an event defined in an EventHandlerList object. If the event has only one handler when removeHandler is called, the event will continue to exist as a placeholder in the EventHandlerList instance.

The addHandler and removeHandler methods also enable you to dynamically change an event in a script component at run time. For example, you can remove a handler from the list during its execution so that it runs only the first time the event is raised.

Example

The following example shows how to call the addHandler and removeHandler methods in a custom control. This is part of a larger example found in the EventHandlerList class overview.

cs

// Bind and unbind to click event.
add_click: function(handler) {
    this.get_events().addHandler('click', handler);
},
remove_click: function(handler) {
    this.get_events().removeHandler('click', handler);
},