ASP. NET custom server control internal details series tutorial 2

Source: Internet
Author: User

If you want to reprint it, Please retain your copyright:
/*
* Description: ASP. NET custom server control internal details series tutorial
* Auther: chongchong-innocent haoban
* MSN: chongchong2008@msn.com
* Dates: 2007-05-20
* Copyright: chongchong2008 Yichang Hubei China
*/

Lifecycle of controls
The lifecycle of the control determines when to save the control and restore its status, when to interact with the page and other controls, when to execute the main processing logic, and when to display the markup text for the output stream.

----------------------------------------
+ Instantiation: Constructor
----------------------------------------
----------------------------------------
+ Initialization: oninit method and init event
----------------------------------------
----------------------------------------
+ Start tracking view status: traceviewstate Method
----------------------------------------

| Only return occurs
-------------------------------------------------------
++ Start tracing view status: traceviewstate Method
-------------------------------------------------------
-------------------------------------------------------
++ Load the returned data: ipostbackdatahandler. loadpostdata Method
-------------------------------------------------------

----------------------------------------
+ LOAD: onload method and load event
----------------------------------------

| only return occurs
-------------------------------------------------------------------
++ triggers the modification event: ipostbackdatahandler. raisepostdatachangedevent method
callback
-----------------------------------------------------------------
++ triggers a callback event: ipostbackeventhandler. raisepostbackevent method
-------------------------------------------------------------------

----------------------------------------
+ Pre-generated: onprerender method and prerender event
----------------------------------------
----------------------------------------
+ Save view status: saveviewstate Method
----------------------------------------
----------------------------------------
+ Generate: render Method
----------------------------------------
----------------------------------------
+ Unload: onUnload method and unload event
----------------------------------------
----------------------------------------
+ Release: dispose method
----------------------------------------

At the end of the initialization phase, the page automatically calls the traceviewstate method of the control. The traceviewstate method ensures that changes generated by using the viewstate dictionary attribute are stored in the Control Chart state after this phase.

The view loading status occurs during the Back-to-pass process, instead of during the initial request process. In this phase, the control must restore its status to the end of processing the previous request, the page framework automatically restores the viewstate dictionary. If the control requires custom State management, you must reload the loadviewstate method to restore the custom state.

In the process of loading the backhaul data and triggering the modification event, this phase occurs only when the control participates in the backhaul data processing through the real ipostbackdatahandler interface.

The callback event triggering phase occurs only when the control participates in callback event processing through the real ipostbackeventhandler interface. You can implement logic by implementing the raisepostbackevent method of the ipostbackeventhandler interface to map client events to server events.

In the pre-generation phase, you should reload the onprerender method to execute any work required before the control is generated, such as registering a client script.

Implement your own server event and callback mechanisms
When the view State is saved, if the control does not maintain the state or uses the viewstate dictionary to save the state information, there is no need to implement any logic in this phase. The page framework automatically saves the viewstate dictionary. If the control needs custom State management, the saveveiwstate method must be reloaded to restore the custom state. After this stage, any changes to the control will not be saved in the control view State.

In the generation phase, the control writes the markup text on the output stream by reloading the render method of control or one of the rendering methods of webcontrol.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.