Atitit. Improving development efficiency The 6-phase comparison of 11 phases of Java JSF using the server Control life cycle (ASP)---
The following is a list of the stages of the server control life cycle .
(1) Initialization-- --in this phase, two main tasks are accomplished: First, initialize the incomingWebThe required settings for the request life cycle, and the tracking view state. First, the page frame is raised by defaultInitevent, and callOnInit ()method, a control developer can override this method to provide initialization logic for the control. After that, the page framework calls thetrackviewstatemethod to track view state. It is important to note that: In most cases,Controlthe base class providestrackviewstatemethod implementation is sufficient. Only when a control defines a complex property can a developer need to overridetrackviewstatemethod.
(2) load view state ---- The Primary task in this phase is to check that the server control exists and that it needs to revert its state to the end of its request before it is processed. Therefore, this process occurs during the page callback process, not the initialization request process. At this stage, the page frame automatically recovers the ViewState dictionary. If the server control does not maintain its state, or if it has the ability to save all its state by default and uses the ViewState Dictionary, then the developer does not have to implement any logic. For situations where data types that cannot be stored in the ViewState dictionary or require custom state management, developers can override the loadviewstate method to customize the recovery and management of the state.
Author:: Old Wow's paw attilax Ayron, email:[email protected]
Reprint please indicate source: Http://blog.csdn.net/attilax
(3) handling postback data ---- to enable the control to check the form data sent back by the client, you must implement the loadpostdata () method of the System.Web.UI.IPostBackDataHandler interface . Therefore, only controls that handle postback data participate in this phase.
(4) load ---- at this stage, the server control in the control tree has been created and initialized, the state is restored, and the form control reflects the client's data. At this point, developers can implement the common logic for each request by overriding the OnLoad () method.
(5send a postback change notification----at this stage, the server control raises the event as a signal that the control state changes due to postback (so that stage is used only for postback). In order to establish this signal, the developer must re-useSystem.Web.UI.IPostBackDataHandlerinterface, and implement another method-raisepostbackchangedevent (). The decision procedure is: if the control state changes due to a postback, theLoadPostData ()returntrue; otherwise returnedfalse. The page frame tracks all returnedtruecontrol and invoke it on these controls .raisepostdatachangedevent ().
(6) handling postback events ---- This phase handles client events that cause postbacks. To facilitate the mapping of client events to server-side events, the developer can do this at this stage by implementing the System.Web.UI.IPostBackEventHandler interface RaisePostBackEvent () method to implement the logic. By this approach, the server control will successfully capture postback client events for server-side processing.
(7 ---- onprerender () method to complete the work. It is important to note that at this stage you can save changes to the state of the control at the present stage, and the changes made during the rendering phase are lost.
(8 ---- If the server control does not maintain state, or it has the ability to save all its states by default, use Span style= "Font-family:times New Roman" >viewstate So the developer does not have to implement any logic at this stage of . This is because the process of saving the state is automatic. If the server control requires custom state saving, or the control cannot be viewstate The dictionary stores special data types, you need to override the saveviewstate () method to achieve state preservation.
(9) The rendering ---- represents The process of writing markup text to the HTTP output stream. The developer makes a custom markup text on the output stream by overriding the Render () method.
Disposal ---- at this stage, the override of the Dispose () method completes the release of a reference to an expensive resource, such as a database link.
(One) unloading ---- the same work done as the " disposition " phase, but developers typically Dispose () method to perform the cleanup without processing the Unload event.
ASP. NET 2.0 server Control Development Essentials - roaming the pitfalls of Microsoft - Blog channel -CSDN.NET.htm
Atitit. Improving development efficiency The 6-phase comparison of 11 phases of Java JSF using the server Control life cycle (ASP)---