
Stages of Page Processing | 47
Web Forms
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
programming logic into event handlers. In ASP.NET, the Page object is the repre-
sentation of your ASP.NET page, and you can write handlers at the page level.
ASP, on the other hand, supports only events at the application and session levels.
The Page class inherits all of its important events from the System.Web. UI.Control
class, which is the ultimate parent of all server controls. This means that all events
described below also apply to both built-in and custom server controls because all
of these controls ultimately derive from
System.Web.UI.Control.
We’ll examine these events in detail. First, however, we’ll examine how an event
is associated with a particular event handler in Visual Basic .NET and C#.
Handling Events
There are three main techniques for handling events in ASP.NET, one of which
takes advantage of ASP.NET’s ability to wire up standard event handlers automat-
ically and two of which rely on wiring up event handlers manually.
Automatic event wiring
When handling events in a page that consists of a single .aspx page, it is often
simplest to create event handlers in the standard
objectname_eventname syntax
familiar to most Visual Basic programmers. By default, ASP.NET will automati-
cally look for handlers such as Page_Init, Page_Load, ...