Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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

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

You're looking for PreLoad, i think.

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.

There's a longer list at ASP.NET 2.0 Event Order (note this is for 2.0).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top