Events in ASP.NET Server Controls

Unlike events in desktop applications, ASP.NET server-control events are raised as well as handled on the server. When a Web request communicates a client-side action to the server, a control can raise events on the server in response to the client action. The event is handled by the page or by its child controls, and ASP.NET sends a response back to the client. This results in a user experience similar to that of a desktop application. However, control developers must understand that only one client-side event is posted to the server — the postback event. Common user-interface events such as mouse clicks or key presses are not communicated to the server and thus cannot be processed on the server.

The base class System.Web.UI.Control provides the events that govern a control's execution lifecycle, such as initialization, loading, and unloading. For the sequence in which these events are executed, see Control Execution Lifecycle. You can handle these events as well as raise additional events from your control. This section shows how to handle inherited events and how to raise custom events.

In This Section