"Order of life and death."
"Install grandchildren."
The last article, "opening" said a lot of empty theory, this article I would first say "Grand" things: 1, asp.net control (including the page itself) the life of the details; 2, how to start the writing of a control.
"Order of life and death."
How does the ASP.net handler, after receiving a user's page request, conjure up a live page to the client? What has it done? In what order?
To illustrate this issue, we first need to understand that a page itself is also a control. From the perspective of design patterns, the page model is a "synthetic mode" (composite), which is itself a structure tree composed of multiple layers of controls, the top layer is page, and the following leaves have branches, leaves are controls that no longer contain child controls, and branches are controls that contain child controls. Each layer of the control's build invokes a method that generates the child control, the parent control invokes the child control's generation method, and the child invokes the grandchild, so recursively, to ensure that all valid (and generally visible=true) controls in the page are processed by the build process, (about the design pattern of things you can view the Lu Zhenyu teacher in the blog Park design Pattern series article, this series is to Dr Yan "Java and the Model" a book (88 yuan, very thick) refining and processing, at least can be used to do the design model shallow level of the teaching material), Each control generally includes the following steps in its lifecycle:
1. Instantiation (Instantiate)
We write controls generally do not touch this activity.
2. Initialization (Initialize)
Ditto.
3. Trace view (Tracking view state) *
This is more important, it involves view state, and in general you do not have to overload this method.
4. Load View status (Load view state) *
This method is invoked only during the return process, as above.
5. Load postback data (load) *
If your control is generated to interact with the client, this method is important and will only be invoked during the return process.