Page and Control Events

The page and controls all have a number of events that are derived from the Control class (or the TemplateControl class, in the case of the Error event). All pass an event argument of type EventArgs that exposes no properties. Some of these events are listed in Table 3-2.

Table 3-2. Some common page and control events

Event name

Description

DataBinding

Occurs when control binds to a data source

Disposed

Occurs when control is released from memory

Error

For the page only, occurs when an unhandled exception is thrown

Init

Occurs when the control is initialized

Load

Occurs when the control is loaded to the Page object

PreRender

Occurs when the control is about to be rendered

Unload

Occurs when the control is unloaded from memory

Tip

Binding a control to a data source means that the control and the data source are tied together so that the control knows to use that data source for populating itself. For a complete description of controls and data binding, see Chapter 9.

Get Programming ASP .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.