End of page of the ASP. NET page life cycle

Source: Internet
Author: User

After the postback event has been processed, the page prepares for the browser-generated output. The rendering phase is divided into two parts: pre-rendering and markup generation. Pre-rendering this sub-stage has two event representations, namely: preprocessing and post processing.

PreRender Events

By handling the event, the page and the control can make any changes to the output before the build is made. The page will first raise its own PreRender event. It then recursively throws all the child controls. Note that the page at this point has ensured that all of its child controls are created.

For a composite control. This phase is particularly important.

Prerendercomplete Events

Because the PreRender event for all child controls is called recursively, the page designer cannot know whether the pre-rendering phase is complete. To do this, the asp.net2.0 version number introduces a new event for the page only. That is, the Prerendercomplete event.

Savestatecomplete Events

In each control is rendered output, for a period of time before the page is generated for markup. To store the state of the current page in the view-state media.

It is worth mentioning that any changes made to the state after that point may be rendered, but will not be stored and cannot be recovered at the next postback. Page state storage is a recursive process, and the page handler iterates through the entire page tree, invoking each control's SaveViewState method. Contains the page itself.

SaveViewState is a protected virtual method (capable of rewriting) that stores the ViewState dictionary content of the current control.

There is also a state type. The so-called "control state", the control state is a private state. is not dictated by application controls. In other words, the control's control state cannot be the same as the view state. is disabled programmatically. The control state is also stored at this time.

He's got a state-state storage mechanism, similar to view state, whose data can also be used to maintain postback between pages, but the purpose of the control state is to maintain the necessary information for the control so that it works correctly. Other words. Property data with state behavior should be saved in the control state, and user interface property data, such as the contents of the control, should be saved in view state.

Generation of Tokens

The markup for the browser is generated. will be completed by each child control individually, and the generated tokens will be stored in a buffer. There are several overriding methods that help developers to mark the stages of the build individually-start the tag, the body, and the end tag.

There are no user events associated with this stage.

Unload events

A recursive call is made after the rendering phase, raising the Unload event for each control, and finally the page itself.

The Unload event is used before the Page object is freed. Run the cleanup work at last. The general operation is closed as a file and a database link.

Notice that the uninstall notification is large before the page or control is about to be unloaded and not yet released. For the actual page, override the Dispose method of the page class. Or just the disposed event of the page, is the last chance to do cleanup before it is freed from memory. The page handler calls the Dispose method to release the Page object. After the recursive invocation of the Unload event handler is complete, it is immediately thrown.

End of page of the ASP. NET page life cycle

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.