Custom Controls, master pages, and content pages exist on ASP. NET pages at the same time.

Source: Internet
Author: User

Events on ASP. NET master pages and content pages
Both the master page and content page can contain the event handler of the control. For controls, events are processed locally, that is, controls on the Content Page trigger events on the Content Page, and controls on the master page trigger events on the master page. Control events are not sent from the content page to the master page. Similarly, you cannot process events from the master page control in the Content Page.
In some cases, the same event is triggered on the Content Page and master page. For example, both triggers the init and load events. The general rule for triggering an event is that the initialization event is triggered from the innermost control to the outermost control, and all other events are triggered from the outermost control to the innermost control. Remember that the master page is merged into the content page and considered as a control in the content page, which is useful at 01:10.

The following shows the sequence of events after the master page and content page are merged:

The init event of the master page control.
Content Control init event.
The init event on the master page.
Content Page init event.
Content Page load event.
Master page load event.
Master page control load event.
Content Control load event.
Content Page prerender event.
The prerender event on the master page.
The prerender event of the master page control.
Content Control prerender event.

The event sequence on the master page and content page is not important to page developers. However, if the event handler you create depends on the availability of some events, you will find it helpful to understand the event sequence on the master page and content page.

Yes. If the event handler you create depends on the availability of some events, you will find it helpful to understand the event sequence on the master page and content page.

 

Order of loading page events in Asp.net

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 the page inherits from another 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

If masterpage is used, the events in masterpage and those in contentpage are activated in the following order:

Contentpage. preinit
Master. init
Contentpage. init
Contentpage. initcomplite
Contentpage. Preload
Contentpage. Load
Master. Load
Contentpage. loadcomplete
Contentpage. prerender
Master. prerender
Contentpage. prerendercomplete

Furthermore, if contentpage inherits the basepage, the execution sequence of each event is changed:

Ui. preinit
Contentpage. preinit
Master. init
Ui. init
Contentpage. init
Ui. initcomplite
Contentpage. initcomplite
Ui. Preload
Contentpage. Preload
Ui. Load
Contentpage. Load
Master. Load
Ui. loadcomplete
Contentpage. loadcomplete
Ui. prerender
Contentpage. prerender
Master. prerender
Ui. prerendercomplete
Contentpage. prerendercomplete

I did not find the Asp.net 1.1 I have learned now. It is estimated that it should be Asp.net 2.0,

But it does not matter, which makes me know the order in which they are loaded during inheritance.

That is, the inherited page is loaded first. If the inherited page has an inherited page, the inherited page is loaded first.

It is actually a very simple content. Write down the page event by the way (I don't know if 1.1 is the case)

 

Init, load, and prerender event execution sequence:
1) Init event of the control
2) Init event on the page where the control is located
3) Load events on the page where the control is located
4) Load events of controls
5) prerender event on the page where the control is located
6) control prerender event

Rule:
1) The init event is triggered from the innermost control (including the user control and common control) to the outermost control (page, load, prerender, and other events are triggered from the outermost control to the innermost control;
2) The execution sequence of the same events between controls depends on the control's position on the page from left to right, from top to bottom.

Note:
1) Remember that the user control is also regarded as a control in the page;
2) using a user control as a special page, the user control itself and its contained controls follow the same rules;
3) Sometimes the onload event of the client body object is used in the client program (such as JavaScript). Note that this client event is the final execution, that is, all events on the server are executed only after they are executed.

The ASP. NET page object model reposted an article on the page object model, which is detailed and helpful for understanding. When it's okay, read it twice and try again later :).

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.