Control life cycle
1. Initialization (corresponding OnInit method)
Here the page through the ProcessRequest method to recursively traverse its child control (that is, the space in the page, in fact, the page is also calculated control). Causes the child controls to call their OnInit methods in turn. Here we can override the control's OnInit method to extend the control functionality or increase the initialization content. The view state tracking feature is also turned on at this stage to invoke the TrackViewState method so that the values stored in the ViewState object can be properly dimmed to the control properties when the page is postback.
2. Load view state (corresponding LoadViewState method)
This stage only executes when the page is postback, loading view state to the control. We didn't get state data stored in view state the first time we visited the page.
3. Load return data (corresponding LoadPostData method)
Executes when the page is postback. LoadPostData implements a method of IPostBackDataHandler that implements the control data return that must inherit the interface, and the method parameter namevaluecollection the object of the type loads the data submitted by the client. In addition, the method also compares the old and new values of the control to return a bool type value to determine whether to execute the RaisePostDataChangedEvent method.
When the customer modifies the form data for submission, the received posted data is a string of key values separated by the "&" symbol, and the page processor matches the posted data collection name to the page control ID one by one, and retrieves the corresponding server control based on the matching ID. IPostBackDataHandler interface to refresh the control's value if it implements the LoadPostData method of the control.
4. Loading (corresponding to the OnLoad method)
The Page_Load () event is invoked when the page is loaded, and the OnLoad method of each control is called in turn.
5. Data postback event notification (corresponding Raisepostdatachangeevent method)
Executes when the page is postback. The method also implements the IPostBackDataHandler interface. This method is executed when the bool value is true to represent the data changes.
6. Triggers the postback event (corresponding RaisePostBackEvent method)
Executes when the page is postback. The main process is to handle the client-side events that caused the postback, and to successfully capture the client events for the postback to handle the server end accordingly. Also implements the IPostBackDataHandler interface. The parameters of this method can be used to determine which control triggers the postback event, and then perform different event handling logic.
7. Pre-presentation (corresponding OnPreRender method)
Some of the processing required before the rendering (render method) is primarily completed. such as registering JavaScript scripts and hiding domain controls.
8. Save view state (corresponding SaveViewState method)
The method is to store the page control view information. The first time the page is requested, the action is performed.
9. Presentation (corresponding Render method)
The control markup and character text are mainly exported to the server control output stream.