2.5. The Client-Side Page Request Lifecycle

ASP.NET developers have been working with the ASP.NET page lifecycle since the first days of ASP.NET 1.0. An ASP.NET developer knows that they are able to interact with the page and its rendering at one of many specific moments in the page request or response lifecycles. For instance, working with page as it is being loaded is as simple as using the Page_Load() event within your page's code-behind.

protected void Page_Load(object sender, EventArgs e)
{
   // Perform desired actions here
}

As with the series of server-side interactions with the page lifecycle, you are also able to interact with the page lifecycle on the client side through a series of page lifecycle events. This is an important feature, and even using DOM today within the browser, you are able to currently work with the page's invocation of the window.onload() and window.onunload() events using JavaScript. However, you are able to work with these two events only when the ASP.NET page does a complete and full page postback. This means that the asynchronous postbacks, or partial-page postbacks, that ASP.NET AJAX performs would be unable to work with such events.

Interacting with the client-side page events is a matter of using the PageRequestManager class provided with ASP.NET AJAX. The PageRequestManager class is the glue between the ScriptManager control on the page and the control that needs to make use of the partial-page updating. The lifecycle provided by the PageRequestManager ...

Get Professional ASP.NET 3.5 AJAX 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.