Order of execution of page_load etc etc
Posted on 2004-10-22
I wanted to just ask a quick question...
I notice in asp.net in visual studio i have a number of methods i.e. Page-Load, Oninit, Intializecomponent etc
Currently I building all my app (well the initializing bit) in page_load i.e. filling variables, binding data to data bound objects etc..
I wanted to know the order of execution for Page_load, oninit, initializecomponent etc etc ... which one executes first??
Would I be better in separating things into Methods i.e. BindDatabase, InitialiseSearchForm and call these from the Page-Load or other method??
Then I was looking at the component at notice there are some remarks (defaults) put in my microsoft
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
So i thought it a bit strange, does microsoft not want us adding details to Oninit, Initializecomponent???? Just interested really, i wanted to use them. Is it the norm to use these???
I know page_load is called everytime the page is loaded i.e even on a postback, when are oninit and intializecomponent called?
anyway I wrote a small app, its a search routine that basically should display some dropdownlists, textboxes etc, there is a button called Advanced Search which if I press it, then more dropdownlists and textboxes would be displayed ... and the .text of Advanced Search would now change to simple search, i.e. Press it and we refer to simple search..
When the page loads initially I wanted a way of setting a variable (session) to equal "simple" - for example (not a real world example)... and then when the button is pressed it can change the variable to "advanced" and visa versa... basically so I can keep track of it..
I can't put the initilization of the variable in the page_load otherwise everytime the page would load it would reinitialize it to "simple", so i was wondering if i could use Onit, or initializecomponent?
Anyway I just wanted to insight into this