Execution sequence instance code of Page events in ASp. NET 2.0 (1/2)

Source: Internet
Author: User

I. Initialization:
1. constructor: Create an instance of the page class and initialize the properties of the page class.
2. addparsedsubobject function:

Protected ure void addparsedsubobject (object obj)


Extract the server controls in the asp tutorial x file and add them to the controlcollection of page. You can use page. controls to obtain all server controls loaded.
3. determinepostbackmode function:
Protected internal virtual namevaluecollection determinepostbackmode ()
Return: namevaluecollection contains the data sent by the user through get or post. If this is the first request, null is returned. the two hidden form fields viewstate and eventtarget will help us determine whether it is the first request. after this event is called, ispostback will be set.
4. oninit function:

Protected internal override void oninit (eventargs e)


Call the init event to initialize all controls in the page as their default values (the value you set on the asp tutorial x page, the value of viewstate is not set to the control at this time)
2. Do not initialize the first request:

1. loadpagestatefrompersistencemedium function:
Protected internal virtual object loadpagestatefrompersistencemedium ()


Load viewstate information to the page Object (the obtained value is not set to the corresponding control)
2. loadviewstate function:

Protected virtual void loadviewstate (object savedstate)


Re-create viewstate information for the control
3. processpostdata function:
A private method cannot be accessed
Obtain user input data and map them to the properties of the corresponding control.
// At this point, the properties of the controls used on the page have been loaded, and your events are shown below.
Iii. event handling
1. onload:

Protected internal virtual void onload (eventargs e)


Call the page_load method to specify the page information. For example, execute the database tutorial query and specify the local variable attribute. (that is, the page_load event we often write)

4. functions that are not executed in the first request are used to call your events:
1. processpostdata: Call the processpostdata function again to process the data information of controls dynamically created in the page_load event.
2. raisechangedevents: responds to the control property change event.
3. raisepostbackevent: Submit event of the response button

5. Handle the onprerender event:
The last chance to modify the property of the control before the page is passed to the browser.

6. At this point, the content of the page cannot be modified. Next, we should prepare the conditions for the next user's postback and generate the corresponding html file.
1. saveviewstate: Because the properties in the server control may be changed in the event, we need to change the information to viewstate.
2. savepagestatetopersistencemedium: saves the viewstate information for the page, that is, saves the obtained viewstat object to a hidden field or session.
3. render: Create an html file and send it to the browser.
4. unload: Release the corresponding resources, such as database tutorial connection and file handle.


The page will be activated in the following order:

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

If a page is inherited from a page, such as basepage: system. web. ui. page, some extensions are made in the basepage, such as permission check. When other pages inherit from the basepage, the order of activation of the events of the basepage and the 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

1 2

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.