views:

114

answers:

1

Ok, I have not been able to really find an answer to this on the internet.. Maybe someone here can help me.

For example, lets say I have a page and 2 custom controls on that page. During what event on page do these controls get constructed. When does their page_init get called?

Also, for these 2 custom controls, do they both get constructed before either of the page_init events get called?

I've done some testing with a debugger and such, but I'm wanting a definite answer to these questions. I'm not wanting to make code that works only sometimes.

+3  A: 

The official page in the documentation describes the page lifecycle in details, but a picture is worth a thousand words :

ASP.Net lifecycle

If I understand correctly, controls are constructed between the PreInit and Init of the page. Thus, controls' Init methods are called before the page's Init method.

According to the schema, Construct and FrameworkInitialize are called on each control before the Init event are fired, which means that all controls should be constructed and available when entering a specific control's Init method.

Wookai
Ok, but this doesn't answer the more important question. Will all of the controls on a page be constructed before calling any of the controls' `init` methods?
Earlz
Oh, sorry, I did not understand the question like that. I will edit my answer.
Wookai
*prints schema and hangs on wall* Wow, that diagram almost gives too much info lol.
Earlz
That's exactly what I did ;) ! Make sure to pring it large enough such that you don't have to come too close to read it !
Wookai