Responding to Web Form Events

The code behind a Web form can respond to any of the page-level events you saw previously in Table 12-2 as well as to events raised by a specific control.

Page_Load is generally the most useful page-level event because it occurs after ASP.NET loads and initializes all the objects on the page, and before ASP.NET renders the page and transmits it to the Web visitor. Visual Studio creates this event handler by default but to create it yourself, you would follow these steps:

  1. Open the Web Forms page in Visual Studio.

  2. Right-click the page and select View Code from the shortcut menu.

  3. In the Class Name drop-down list box (which appears in the top-left corner of the code editor) select Base Class Events.

  4. In the Method Name ...

Get Faster Smarter Beginning Programming 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.