views:

177

answers:

1

From the ASP.Net Page Lifecycle article on MSDN:

Although both Init and Load recursively occur on each control, they happen in reverse order. The Init event (and also the Unload event) for each child control occur before the corresponding event is raised for its container (bottom-up). However the Load event for a container occurs before the Load events for its child controls (top-down).

This makes a lot of sense for the unload event, but why for init? What about the other events?

Kind regards,

+4  A: 

This is due to how these pages are created - the user controls are properties of the page's class. They are created (and hence initialised) as the class is initialised, which ensures that their instances are available during the constructor and page's init event.

Then when load, prerender and render events occur the page's event fires first and cascades the events for everything inside it.

When the unload and dispose come around the property objects are dealt with first again.

The WebForm page event model is a little too complicated, IMHO.

Keith