.Net学习笔记 - ASP.NET页面的执行顺序

本文详细介绍了ASP.NET页面从初始化到卸载的整个生命周期过程,包括关键事件如OnInit、OnLoad及OnPreRender等的触发顺序,并特别分析了使用母版页时的事件处理流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[完全版]
Page calls Construct
Page finishes Construct
Page calls New
Page finishes New
Page calls DeterminePostBackMode
Page finishes DeterminePostBackMode
Page calls AddParsedSubObject
Page calls CreateControlCollection
Page finishes CreateControlCollection
Page calls AddedControl
Page finishes AddedControl
Page finishes AddParsedSubObject
ChildControl calls Construct
ChildControl finishes Construct
ChildControl calls New
ChildControl finishes New
Page calls AddParsedSubObject
Page calls AddedControl
Page finishes AddedControl
Page finishes AddParsedSubObject
Page calls AddParsedSubObject
Page calls AddedControl
Page finishes AddedControl
Page finishes AddParsedSubObject
ChildControl calls OnInit
ChildControl raises Init
ChildControl finishes OnInit
ChildControl calls TrackViewState
ChildControl finishes TrackViewState
Page calls OnInit
Page raises Init
Page finishes OnInit
Page calls TrackViewState
Page finishes TrackViewState
Page calls OnLoad
Page raises Load
Page finishes OnLoad
ChildControl calls OnLoad
ChildControl raises Load
ChildControl finishes OnLoad
Page calls EnsureChildControls
Page calls CreateChildControls
Page finishes CreateChildControls
Page finishes EnsureChildControls
Page calls OnPreRender
Page raises PreRender
Page finishes OnPreRender
ChildControl calls EnsureChildControls
ChildControl calls CreateChildControls
ChildControl finishes CreateChildControls
ChildControl finishes EnsureChildControls
ChildControl calls OnPreRender
ChildControl raises PreRender
ChildControl finishes OnPreRender
Page calls SaveViewState
Page finishes SaveViewState
ChildControl calls SaveViewState
ChildControl finishes SaveViewState
Page calls SavePageStateToPersistenceMedium
Page finishes SavePageStateToPersistenceMedium
Page calls CreateHtmlTextWriter
Page finishes CreateHtmlTextWriter
Page calls Render
Page finishes RenderChildren
ChildControl calls Render
ChildControl calls RenderChildren
ChildControl finishes RenderChildren
ChildControl finishes Render
Page finishes RenderChildren
Page finishes Render
ChildControl calls OnUnload
ChildControl raises Unload
ChildControl finishes OnUnload
Page calls OnUnload
Page raises Unload
Page finishes OnUnload
 
----- 说明:除了Init()和Unload()之外的所有事件都是从最外面到最里面被激发的 
 
[MasterPage版]
  1. ContentPage.PreInit
  2. Master.Init
  3. ContentPage.Init
  4. ContentPage.InitComplete
  5. ContentPage.PreLoad
  6. ContentPage.Load
  7. Master.Load
  8. ContentPage.LoadComplete
  9. ContentPage.PreRender
  10. Master.PreRender
----- 说明:使用母版页时的特例,我们先要了解一个非常重要的知识点——母版页被处理的过程就相当于内容页中的一个控件,这个原因就是内容页中的所有控件都包含在“ContentPlaceholder”里,而ContentPlaceholder”其实就是母版页的一个子控件。现在母版页被处理的过程就相当于内容页中的一个控件,我们早先提到过,除了Init()和Unload()之外的所有事件都是从最外面到最里面被激发的,所以是先ContentPage.Load再Master.Load(Master现在是内容页中的一个子控件)。
 
[简化版]
OnInit
TrackViewState
OnLoad
EnsureChildControls
CreateChildControls
OnPreRender
SaveViewState
Render
RenderChildren
OnUnload
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值