Using System.Data;
Using System.Configuration;
Using System.Web;
Using System.Web.Security;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Web.UI.WebControls.WebParts;
Using System.Web.UI.HtmlControls;
Public partial class _default:page {#region Onpreinit first step protected override void Onpreinit (EventArgs e) {
Check the IsPostBack property to determine if the page is being processed for the first time.
Create or recreate a dynamic control.
Dynamically set the master page.
Dynamically set the Theme property.
Reads or sets the profile property value. Note//If the request is a postback, the value of the control has not been restored from view state.
If you set control properties at this stage, their values may be overridden in the next event. Base.
Onpreinit (e); #endregion #region OnInit The second step protected override void OnInit (EventArgs e) {//All controls are initialized and all applications have been applied outside of the View set to raise.
Use this event to read or initialize the properties of a control. Base.
OnInit (e); #endregion #region Oninitcomplete The third step protected override void Oninitcomplete (EventArgs e) {//By Raised by the Page object.
Use this event to handle tasks that require you to complete all initialization work first. Base.
Oninitcomplete (e); #endregion #region Preload fourth step protected override void Onpreload (EventArgs e)
{The value of the//html server control is in a secondary recovery (value has been restored)///If you need to perform processing on the page or control before the Load event, use the event.
After the Page raises the event, it loads view state for itself and all controls, and then handles any postback data that is included with the Request instance. Base.
Onpreload (e); #endregion #region OnLoad Fifth step protected override void OnLoad (EventArgs e) {//page called on the Page O
Nload the event method, and then recursively performs the same operation on each child control,//So it repeats until the page and all the controls are loaded.
Use the OnLoad event method to set properties in the control and establish a database connection. Base.
OnLoad (e); #endregion #region Step Sixth protected void Page_Load (object sender, EventArgs e) {//What else do you want me to say? All the people in the world know After execution, then executes the user control's Page_Load () event} #endregion The seventh step of the #region control event protected void Button1_Click (object s
Ender, EventArgs E) {///Use these events to handle specific control events, such as the Click event of a Button control or the TextChanged event of a TextBox control.
Note//In a postback request, if the page contains a validator control, check the IsValid property of the page and each validation control before performing any processing. #endregion #region Onloadcomplete Eighth step protected override void Onloadcomplete (EventArgs e) {//Pair
The task that needs to load all other controls on the page uses the event. Base. Onloadcomplete (E); #endregion #region OnPreRender nineth step protected override void OnPreRender (EventArgs e) {//Before this event occurs
: The//page object calls EnsureChildControls for each control and page.
Each data-bound control that has the DataSourceID property set invokes the DataBind method.
For more information, see Data-binding events for data-bound controls below. PreRender events occur for each control on the page.
Use this event to make a final change to the contents of a page or its controls. Base.
OnPreRender (e);
#endregion #region Savestatecomplete Tenth step protected override void Onsavestatecomplete (EventArgs e) { ViewState was saved for the page and for all controls before the event occurred.
Any changes made to the page or control at this time will be ignored.
Use this event to perform a task that requires that view state has been saved, but that no changes have been made to the control. Base.
Onsavestatecomplete (e);
#endregion #region Render 11th Step//render//This is not an event; At this stage of processing, the Page object will be raised on each control with this method.
All asp.net Web server controls have a Render method for writing a control tag that is set to be sent to the browser.
If you create a custom control, you typically override this method to output the markup for the control.
However, if your custom control merges only standard asp.net Web server controls and does not incorporate custom tags, you do not need to override the Render method.
For more information, see Developing custom ASP.net server controls.
The user control (. ascx file) automatically merges the rendering, so you do not need to render the control explicitly in your code. #endregion #region OnUnload 12th step protected override void OnUnload (EventarGS e) {//This event occurs first for each control and then for that page.
In a control, use this event to perform a final cleanup of a specific control,//such as closing a control-specific database connection.
For the page itself, use this event to perform the final cleanup work, such as closing open files and database connections, or completing logging or other request-specific tasks.
Note//During the uninstall phase, the page and its controls have been rendered so that no further changes can be made to the response stream.
If you try to invoke a method, such as the Response.Write method, the page throws an exception. Base.
OnUnload (e); } #endregion}
The order in which master pages and content pages are executed:
The init of the Init-> content page of the Init-> master page for the Init-> content page control of the control in the master page
-> the control's load in the Load-> content page of the Load-> master page of the content page
The PreRender of the control in the Prerender-> content page of the Prerender-> Master page control of the-> content page prerender-> master page
This article is reproduced in: http://www.cnblogs.com/henw/archive/2012/02/09/2343994.html