asp.net 2.0 execution sequence instance code for page events (1/2)

Source: Internet
Author: User

I. Initialization section:
1. Constructor: Creates an instance of the page class that initializes the properties of the page class.
2.addparsedsubobject function:

protected virture void AddParsedSubObject (object obj)


Extracts the server controls in the ASP tutorial X files and adds them to the page's ControlCollection. You can get all the server controls loaded by Page.controls
3.determinepostbackmode function:
Protected internal Virtual NameValueCollection DeterminePostBackMode ()
Return: NameValueCollection contains data sent by the user via Get or post, and returns empty if the first request is made. ViewState and eventtarget these two hidden form fields will help us to determine whether this is the first request. After this event is invoked, the IsPostBack will be set.
4.oninit function:

protected internal override void OnInit (EventArgs e)


Invoke the Init event to initialize all controls in the page to their default values (values that you set in the ASP Tutorial x page, viewstate values are not set to the control)
Two. Non-initialization of the first request:

1.loadpagestatefrompersistencemedium Function:
Protected internal Virtual Object LoadPageStateFromPersistenceMedium ()


Load viewstate information into the Page object (at which point the obtained value is not set to the corresponding control)
2.loadviewstate function:

protected virtual void LoadViewState (object savedstate)


To re-establish viewstate information for a control
3.processpostdata function:
A private method that cannot be accessed
Gets the data entered by the user and maps them to the properties of the corresponding control
The properties of the controls that are used on this page are loaded, and the following is the appropriate event for you
Three. Event Processing Section
1.onload:

protected internal virtual void onload (EventArgs e)


Call the Page_Load method to specify the page information, such as performing a database tutorial query, specifying the local variable properties. (which is the Page_Load event that we often write)

Four. Functions that are not required for the first request are used to invoke the various events you have written:
1.processpostdata: Call the Processpostdata function again primarily to handle the data information of the control that was dynamically created in the Page_Load event
2.raisechangedevents: Responding to control property Change event
3.raisepostbackevent: Submit Event for Response button

Five. Handling OnPreRender Events:
The last chance to modify control properties before the page is passed to the browser

Six. The content on this page cannot be modified, so the next time the user's postback is ready for the condition and the corresponding HTML file is generated.
1.saveviewstate: Because the properties in the server control may have been changed in the event, we need to change the information into the ViewState
2.savepagestatetopersistencemedium: Save ViewState State information for the page, which is to save the Viewstat object obtained above to a hidden field or session
3.render: Create an HTML file and send it to the browser
4.unload: Release the appropriate resources, such as database tutorial connection, file handle, etc.


The event is activated in page execution in the following order:

Page.preinit
Page.Init
Page.initcomplite
Page.preload
Page.load
Page.loadcomplete
Page.prerender
Page.prerendercomplete

If a page inherits from a page, such as basepage:system.web.ui.page, some extensions are made in basepage, such as permission checks, and other pages inherit from BasePage, then the event activation order for BasePage and final page is:

Ui.preinit
Page.preinit
Ui.init
Page.Init
Ui.initcomplite
Page.initcomplite
Ui.preload
Page.preload
Ui.load
Page.load
Ui.loadcomplete
Page.loadcomplete
Ui.prerender
Page.prerender
Ui.prerendercomplete
Page.prerendercomplete

Home 1 2 last page
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.