Copy Code code as follows:
Sixth Step #region Control event
protected void Button1_Click (object sender, 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.
Attention
In a postback request, if the page contains a validator control, check the IsValid properties of the page and each validation control before performing any processing.
}
#endregion
#region Onloadcomplete Seventh Step
protected override void Onloadcomplete (EventArgs e)
{
Use this event for tasks that need to load all other controls on the page.
Base. Onloadcomplete (e);
}
#endregion
#region OnPreRender Eighth Step
protected override void OnPreRender (EventArgs e)
{
Before this event occurs:
The Page object invokes 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 nineth 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 Tenth Step
Render
This is not an event; At this stage of processing, the Page object will be raised with this method on each control. 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 11th 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.
Attention
In the uninstall phase, the page and its controls are rendered and cannot be further changed for 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
}
When the page is postback, such as clicking the button, the above events will be executed again, and the Order of execution is:
1. Onpreinit
2. OnInit
3. Oninitcomplete
4. Onpreload
5. Page_Load
6. OnLoad
7. Button_Click
8. Onloadcomplete
9. OnPreRender