Asp. NET life cycle of a page

Source: Internet
Author: User

Before learning the ASP. NET page life cycle, you need to understand the basic operating mechanism of the previous ASP, after understanding the basic operating mechanism of ASP, the following will describe the life cycle of ASP, the page from creation to processing end of the process of ASP. 10 events performed by the engine.

1. Object initialization

The page itself and the controls on the page are initialized for the first time in the form, and initialization events can be overloaded by the OnInit () method. By declaring an object in the constructor of the background code file in the ASPX page, the page will know the type of the object, And you know how many such objects you need to create. Once a control is declared in the constructor, it can be accessed in any of its child class event methods or properties. However, if the object is a control that is specified in an ASPX file, because such a control is not a property, and doing so is dangerous to access them from code, There is no guarantee that the control instances will be created in any order.

2. Load view state data

After initialization, because the document object model for relative references has not yet been established, the control can only be referenced by ID. In the LoadViewState event, the initialized control obtains the first property, the view state information that was last committed to the server. Page view state is maintained through ASP. It is often used to persist information to the server in a round trip. The view state information is saved as a name/value pair that contains the text and value of the control. View information is passed in a page request and is usually saved in a hidden <input> The Value property of the control. This event can be overloaded with the LoadViewState () method, which is often used to customize the data that it accepts when the control is populated.

3.LoadPostData Processing of postback data

During the creation of the page, the form data sent to the server side (also known as postback data) is processed according to the data requirements of each control. When the page submits the form, the framework implements the IPostBackDataHandler interface on each control that submits the data. Then, The page fires the LoadPostData event, discovers the control that implements the IPostBackDataHandler interface through page parsing, and updates the control state with the correct callback data. Asp. NET updates the correct control is implemented by matching the control's unique identifier, which has a name-value pair in the collection of name values.

4. Object loading


5. Triggering raisepostdatachanged Events

6. Handling Client Backhaul Events

Asp. NET life cycle of a page

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.