Do you need to know the page life cycle?

Do you need to know the page life cycle?

If you develop custom controls, you must be familiar with the page life cycle in order to correctly initialize controls, populate control properties with view-state data, and run control behavior code. The life cycle of a control is based on the page life cycle, and the page raises many of the events that you need to handle in a custom control.

How does the server life cycle work in ASP.NET?

Individual ASP.NET server controls have their own life cycle that is similar to the page life cycle. For example, a control’s Init and Load events occur during the corresponding page events. Although both Init and Load recursively occur on each control, they happen in reverse order.

How are control events handled in ASP.NET?

For control events, you bind the event handler to the event, either declaratively using attributes such as onclick, or in code. Pages also support automatic event wire-up, meaning that ASP.NET looks for methods with particular names and automatically runs those methods when certain events are raised.

What happens during page initialization in ASP.NET?

During page initialization, controls on the page are available and each control’s UniqueID property is set. A master page and themes are also applied to the page if applicable. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.

What is the purpose of the page lifecycle API?

The Page Lifecycle API attempts to solve this problem by: Introducing and standardizing the concept of lifecycle states on the web. Defining new, system-initiated states that allow browsers to limit the resources that can be consumed by hidden or inactive tabs.

Can a page be in more than one lifecycle state?

All Page Lifecycle states are discrete and mutually exclusive, meaning a page can only be in one state at a time. And most changes to a page’s lifecycle state are generally observable via DOM events (see developer recommendations for each state for the exceptions).