Page 生命周期

类别消息From First(s)From Last(s)
aspx.pageBegin PreInit
aspx.pageEnd PreInit0.006248714623158710.006249
aspx.pageBegin Init0.006945538617695160.000697
aspx.pageEnd Init0.01217515961479420.005230
aspx.pageBegin InitComplete0.0123327807121420.000158
aspx.pageEnd InitComplete0.01272433726183090.000392
aspx.pageBegin PreLoad0.01337225490748920.000648
aspx.pageEnd PreLoad0.01376918478975960.000397
aspx.pageBegin Load0.01391189388670640.000143
aspx.pageEnd Load0.01806334467397230.004151
aspx.pageBegin LoadComplete0.01823099565797640.000168
aspx.pageEnd LoadComplete0.0186172791238260.000386
aspx.pageBegin PreRender0.01875835416627510.000141
aspx.pageEnd PreRender0.028637336390920.009879
aspx.pageBegin PreRenderComplete0.02931521838561930.000678
aspx.pageEnd PreRenderComplete0.02992126213166420.000606
aspx.pageBegin SaveState0.07223189539043750.042311
aspx.pageEnd SaveState0.1443378081865630.072106
aspx.pageBegin SaveStateComplete0.1445050180761010.000167
aspx.pageEnd SaveStateComplete0.1449442529275770.000439
aspx.pageBegin Render0.1450879845616940.000144
aspx.pageEnd Render0.2442948165134740.099207
    

A page in an ASP.NET application consists of several server controls. These are the fundamental building blocks of an ASP.NET application. The Life cycle of an ASP.NET page, depends on whether the page is requested for the first time or it is a postback. Postback is a process by which a page can request for itself.

When the Page is requested for the first time

The Life Cycle of a page when requested for the first time:

Initializing: During this phase, the server creates an instance of the server control

Loading: During this phase, the instance of the control is loaded onto the page object in which it is defined.

PreRendering: During this phase, the control is updated with the changes made to it. This prepares the control for rendering.

Saving: During this phase, the state information of the control is saved. For example, if a value is set for the control during the Load event, it is embedded in the HTML tag that will be returned to the browser.

Rendering: During this phase, the server creates the corresponding HTML tag for the control.

Disposing: During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.

Unloading: During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is the final event in the life cycle of a server control

Life cycle when the page processed during a postback event

The processing sequence in which a page is processed during a postback event is:

Initializing: During this phase, the server creates an instance of the server control

Loading view state: During this phase, the view state of the control posted by the client is reloaded into the new instance of the control.

Loading: During this phase, the instance of the control is loaded onto the page object in which it is defined.

Loading the postback data: During this phase, the server searches any data corresponding to the control that is loaded in the data posted by the client.

PreRendering: During this phase, the control is updated with the changes made to it. This prepares the control for rendering.

Saving state: During this phase, the change in the state of control between the current request and the previous request of the page is saved. For each change, the corresponding event is raised. For example, if the text of a textbox is changed, the new text is saved and a text_change event is raised.

Rendering: During this phase, the server creates the corresponding HTML tag for the control.

Disposing: During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.

Unloading: During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is the final event in the life cycle of a server control

The events associated with the relevant page cycle phases are:

  • Page Initialization: Page_Init

  • View State Loading:LoadViewState

  • Postback data processing: LoadPostData

  • Page Loading: Page_Load

  • PostBack Change Notification: RaisePostDataChangedEvent

  • PostBack Event Handling: RaisePostBackEvent

  • Page Pre Rendering Phase: Page_PreRender

  • View State Saving: SaveViewState

  • Page Rendering: Page_Render

  • Page Unloading: Page_UnLoad

The following figure illustrates how the server controls on an ASP.NET page is processed by the server:



转载于:https://www.cnblogs.com/duhui-cnblogs/articles/1135510.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值