Export (0) Print
Expand All
4 out of 5 rated this helpful - Rate this topic

Control.Events Property

Gets a list of event handler delegates for the control. This property is read-only.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
protected EventHandlerList Events { get; }
/** @property */
protected EventHandlerList get_Events ()

protected function get Events () : EventHandlerList

Not applicable.

Property Value

The list of event handler delegates.

This property is of type EventHandlerList, which uses a linear search algorithm to find entries in the list of delegates. A linear search algorithm is inefficient when working with a large number of entries. Therefore, when you have a large list, finding entries with this property will be slow.

The following example creates an event, named Click, that adds and removes handlers from the control's EventHandlerList collection when the event is called from a page.

Note   This example optimizes how a control adds and removes events from the list of them that the control maintains. If you create custom control and want to define an event, use code similar to this. This technique can be used in C#, but not in Visual Basic.

// Create an event that adds and removes handlers from the
// Control.Events collection when this event is called from
// a participating page.
public event EventHandler Click {
    add {
        Events.AddHandler(EventClick, value);
    }
    remove {
        Events.RemoveHandler(EventClick, value);
    }
}

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.