ASP. C # master page and content page event typesetting load order life cycle
About ASP page Page_Load occurred before the event caused by the problem has been loved, the explanation of the problem is also very comprehensive, but how to solve the problem is less people say, I will
Simply explain the solution. The following is the order of events for the content and master pages (if any):
Contentpage.preinit
Master.init
Contentpage.init
Contentpage.initcomplite
Contentpage.preload
Contentpage.load
Master.load
Contentpage.loadcomplete
Contentpage.prerender
Master.prerender
Contentpage.prerendercomplete
Even if the order of occurrence is not good for the novice, the following emphasis will come:
We will find a protected void Page_Load (object sender, EventArgs e) method in the background of the page
It is common for people to write the processing code that needs to be done when the page is loaded, but this method occurs before the Click event, causing a lot of minor problems
so is there a way to do it after the event? The answer is yes:
protected void Page_loadcomplete (object sender, EventArgs e)
is it simple? But this method still occurs before the master load, if the pop-up dialog will cause the master layout confusion, then use the following is OK
protected void Page_prerendercomplete (object sender, EventArgs e)
So the life cycle of the problem is solved, the code understanding is much smoother
Here are some of the method execution sequences that will be activated during page loading, which can be used if you want to write code at a specific stage of the page:
protected void Page_Init (object sender, EventArgs e)
protected void Page_Load (object sender, EventArgs e)
Various user-defined control click events
protected void Page_loadcomplete (object sender, EventArgs e)
protected void Page_PreRender (object sender, EventArgs e)
protected void Page_prerendercomplete (object sender, EventArgs e)
protected void Page_Unload (object sender, EventArgs e)
protected void Page_Error (object sender, EventArgs e)
protected void Page_aborttransaction (object sender, EventArgs e)
protected void Page_committransaction (object sender, EventArgs e)
protected void Page_databinding (object sender, EventArgs e)
protected void page_disposed (object sender, EventArgs e)
ASP. C # master page and content page event typesetting load order life cycle