views:

719

answers:

4

Which are the events of an ASP .Net server control and how does their order relate to the containing page's events?

The concrete problem is that I am looking for an event inside the server control that fires before the *Page_Load* event of the containing page.

+1  A: 

This should help: http://msdn.microsoft.com/en-us/library/ms178472.aspx

You're looking for PreLoad, i think.

Abyss Knight
A: 

It's a littlebit problem, because the control can be placed inside the page after the "Page_Load" event.

In one my historic project, I derived all pages from my class "PageEx : System.Web.UI.Page". Which had a property "CurrentState" of type "enum PageStates { PreInit, Init, PostInit, PreLoad, /* etc... */ }". Than all my controls was able recognized state of page cycle.

TcKs
+1  A: 

Check out this page. It will let you know what events fire when. Looks like you could use the PreLoad event.

Craig
+2  A: 

With regards to how they relate to Page events, at least for Init and Load:

"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)."

From http://msdn.microsoft.com/en-us/library/ms178472.aspx

Corbin March