ASP.NET Page event basics

Written by Brett Veenstra

In ASP.NET 1.1 there are four major events that fire for the Page class (System.Web.UI.Page). Here’s a hack of an explanation:

  1. Init - page class is instantiated in ASP.NET worker process. Advisable to instantiate private members of your class here but hold off on much else as the web UI controls can get modified in later events
  2. Load - ControlTree is created, all PostBack data has already been posted to the controls, all ViewState has been processed, this is the place to rearrange controls, visibility and dynamically create controls
  3. PreRender - last chance to alter web controls - you cannot OVERRIDE this event
  4. Unload - output has been written, and you’re just doing cleanup now

For a detailed discussion into all ten, check out 4GuysFromRolla.com