ASP.NET Web Parts Life Cycle

When controls from the ASP.NET Web Parts integrated set of controls are included within a Web page, they obey that page's rules; in particular, they operate within the page's life cycle.

A Web page goes through a life cycle in which it performs a series of processing steps. These steps include initialization, control creation, restoring and maintaining state, running event handler code, and rendering. It is important for you to understand the page life cycle and how it applies to Web Parts so you can implement your logic at the appropriate phase in the cycle. In particular, you must familiarize yourself with the page life cycle to properly initialize the Web Parts controls, populate properties with personalization data, and run any behavior logic.

Web Parts Life Cycle Phases

This section provides detailed information about the Web Parts life cycle phases, as shown in the following illustration.

Web Parts Life Cycle

Web Parts Life Cycle

Initialization

The following main tasks are performed during the initialization phase:

If you need to programmatically set the properties for a GenericWebPart control, you should do it during this phase so that these properties are available at the proper time, for example when personalization is loaded.

Initialization Complete

The following main tasks are performed during this phase:

Load Complete

The following main task is performed during this phase:

Note

During the load complete phase, you can set the values of properties that are not marked as personalizable. At this stage, the WebPartManager control performs some final initialization on the Web Parts controls it manages.

Save State Complete

The following main tasks are performed during this phase:

  • The WebPartManager control extracts the personalization information from the static and dynamic WebPart objects.

  • The WebPartManager control saves the static and dynamic WebPart objects' personalization information in permanent storage.

See Also

Tasks

Walkthrough: Creating a Web Parts Page

Reference

Web Parts Control Set Overview

System.Web.UI.WebControls.WebParts

WebPartManager

WebPart

WebPartZone

WebPartConnection

Concepts

Web Parts Personalization Overview

ASP.NET Page Life Cycle Overview

ASP.NET Application Life Cycle Overview for IIS 5.0 and 6.0