Asp. How do events in net occur sequentially? _ Practical Tips

Source: Internet
Author: User

This paper introduces the sequence of event execution in asp.net by means of actual combat.

Method/Step

Create a new C # WebForm project, as shown in the following illustration:

Add a button control in the Defualt.aspx file and name it Button1, and then add an event handler for each event for the control and add a breakpoint, as shown in the following figure:

Open the Global.asax file and add a breakpoint, as shown in the following figure:

Open the Site.master code file Site.Master.cs and add breakpoints, as shown in the following figure:

Press F5 to run, and view the sequence of code runs: Application_start→session_start→button1_init→page_load (defualt.asp) →page_ Load (site.master) →button1_load→button1_prerender→button1_unload→ display interface.

When we shut down IIS, we execute: session_end→application_end.

Summarize:

1. Execute the Application_Start function when you start the Web site through IIS, and execute the Application_End function when you close the Web site. These two functions can be thought of as being invoked by IIS.
2, when there is a new connection request to execute the Session_Start function, this time can use the session object, when the user does not operate for a long time, more than the session length, the implementation of the Session_End function. These two functions can also be thought of as IIS calls.
3. When requesting an ASPX page, the init function of all controls is executed first, then the Page_Load function of the page is executed, if there is a motherboard and then executes the Page_Load function of the motherboard, then executes the control's load function, PreRender function, unload function, The corresponding interface is displayed when all server controls have executed these functions.

Now we have a general understanding of how events in asp.net occur in turn, and hope to help you learn the sequence of events in asp.net.

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.