ASP.NET页面的执行顺序
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 parses templated properties here and calls Set for those properties on the ChildControl (e.g., <tag:namespace id=攊dName?runat=攕erver?FirstName=擜dam?LastName=擶ayne?DisplayBothNames=擳rue?/u> />)
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
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
在WebForm1页面上直接放置用户控件WebUserControl1时的事件顺序: WebUserControl1_Init
WebForm1_Init
Page_Load
WebUserControl1_Load
WebForm1_PreRender
WebUserControl1_PreRender
WebUserControl1_Unload
WebForm1_Unload
在WebForm1页面的OnInit方法中用代码Load用户控件WebUserControl1时的事件顺序: WebForm1_Init : OnInit WebForm1: Loading controls WebUserControl1_Init : OnInit WebForm1: added to Controls WebForm1: LoadViewState WebUserControl1: LoadViewState WebUserControl1: LoadPostData Begin WebUserControl1: LoadPostData End WebForm1_PageLoad: OnLoad after base's Onload. WebUserControl1_Load: after base's OnLoad iWebUserControl1: RaisePostDataChange WebForm1: OnPreRender WebUserControl1: OnPreRender WebForm1: SavedViewState WebUserControl1: SaveViewState 在WebForm1页面的Page_Load方法中用代码Load用户控件WebUserControl1时的事件顺序: WebForm1_Init : OnInit WebForm1: LoadViewState WebForm1_PageLoad: OnLoad after base's Onload. WebForm1: Loading controls WebUserControl1_Init : OnInit WebUserControl1: LoadViewState WebForm1: added to Controls WebUserControl1_Load: after base's OnLoad WebUserControl1: LoadPostData Begin WebUserControl1: LoadPostData End iWebUserControl1: RaisePostDataChange WebForm1: OnPreRender WebUserControl1: OnPreRender WebForm1: SavedViewState WebUserControl1: SaveViewState 在WebForm1页面的Button1_Click事件中用代码Load用户控件WebUserControl1时的事件顺序: WebForm1_Init
Page_Load
Button1_Click
WebUserControl1_Init
WebUserControl1_Load
WebForm1_PreRender
WebUserControl1_PreRender
WebUserControl1_Unload
WebForm1_Unload
在WebForm1页面的Page_Load事件中用代码Load用户控件WebUserControl1,WebUserControl1又在Page_Load事件中用代码Load用户控件WebUserControl2时的事件顺序: WebForm1_Init
Page_Load
WebUserControl1_Init
WebUserControl1_Load
WebUserControl2_Init
WebUserControl2_Load
WebForm1_PreRender
WebUserControl1_PreRender
WebUserControl2_PreRender
WebUserControl2_Unload
WebUserControl1_Unload
WebForm1_Unload
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
ProcessRequest方法执行过程:
页面事件
可重定义的方法
页面初始化(Init,当Init事件发生时,代表所有在.aspx文件中静态声明的控件被实例化
并被赋予了默认值,在Init事件中可以初始化任何的在页面生命周期里需要的设置,
需要注意的是,任何的视图状态信息在这个阶段里是不能用的)
视图状态加载(LoadViewState,__VIEWSTATE是 名称/值 对的集合,
象LoadPageStateFormPersistenceMedium这样的方法和与其相对应的
SavePageStateToPersistenceMedium 方法可以用来加载或者保存视图状态
到其他的存储中介里,和LoadViewState方法不相同的是,上面提到的方法
只能在Page的继承类里使用)
回传数据处理(控件里实现了IPostBackDataHandler接口的LoadPostData方法 )
页面加载 (Load)
回传数据变化检查(控件里实现了IPostBackDataHandler接口的RaisePostDataChangedEvent方法)
回传事件处理(控件里定义的回传事件.控件里实现了IPostBackEventHandler接口的RaisePostBackEvent方法)
页面预返回阶段(PreRender,SaveViewState)
页面返回阶段(Render)
页面卸载阶段(Unload)
ProcessRequest方法最先调用的是其所在类(Page)重载实现的基类System.Web.WebControls.TemplateControl的"FrameworkInitialize”虚拟方法,页面的控件树就在这个时候产生。
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
在WebForm1页面上直接放置用户控件WebUserControl1时的事件顺序: WebUserControl1_Init
WebForm1_Init
Page_Load
WebUserControl1_Load
WebForm1_PreRender
WebUserControl1_PreRender
WebUserControl1_Unload
WebForm1_Unload
在WebForm1页面的OnInit方法中用代码Load用户控件WebUserControl1时的事件顺序: WebForm1_Init : OnInit WebForm1: Loading controls WebUserControl1_Init : OnInit WebForm1: added to Controls WebForm1: LoadViewState WebUserControl1: LoadViewState WebUserControl1: LoadPostData Begin WebUserControl1: LoadPostData End WebForm1_PageLoad: OnLoad after base's Onload. WebUserControl1_Load: after base's OnLoad iWebUserControl1: RaisePostDataChange WebForm1: OnPreRender WebUserControl1: OnPreRender WebForm1: SavedViewState WebUserControl1: SaveViewState 在WebForm1页面的Page_Load方法中用代码Load用户控件WebUserControl1时的事件顺序: WebForm1_Init : OnInit WebForm1: LoadViewState WebForm1_PageLoad: OnLoad after base's Onload. WebForm1: Loading controls WebUserControl1_Init : OnInit WebUserControl1: LoadViewState WebForm1: added to Controls WebUserControl1_Load: after base's OnLoad WebUserControl1: LoadPostData Begin WebUserControl1: LoadPostData End iWebUserControl1: RaisePostDataChange WebForm1: OnPreRender WebUserControl1: OnPreRender WebForm1: SavedViewState WebUserControl1: SaveViewState 在WebForm1页面的Button1_Click事件中用代码Load用户控件WebUserControl1时的事件顺序: WebForm1_Init
Page_Load
Button1_Click
WebUserControl1_Init
WebUserControl1_Load
WebForm1_PreRender
WebUserControl1_PreRender
WebUserControl1_Unload
WebForm1_Unload
在WebForm1页面的Page_Load事件中用代码Load用户控件WebUserControl1,WebUserControl1又在Page_Load事件中用代码Load用户控件WebUserControl2时的事件顺序: WebForm1_Init
Page_Load
WebUserControl1_Init
WebUserControl1_Load
WebUserControl2_Init
WebUserControl2_Load
WebForm1_PreRender
WebUserControl1_PreRender
WebUserControl2_PreRender
WebUserControl2_Unload
WebUserControl1_Unload
WebForm1_Unload
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
ProcessRequest方法执行过程:
页面事件
可重定义的方法
页面初始化(Init,当Init事件发生时,代表所有在.aspx文件中静态声明的控件被实例化
并被赋予了默认值,在Init事件中可以初始化任何的在页面生命周期里需要的设置,
需要注意的是,任何的视图状态信息在这个阶段里是不能用的)
视图状态加载(LoadViewState,__VIEWSTATE是 名称/值 对的集合,
象LoadPageStateFormPersistenceMedium这样的方法和与其相对应的
SavePageStateToPersistenceMedium 方法可以用来加载或者保存视图状态
到其他的存储中介里,和LoadViewState方法不相同的是,上面提到的方法
只能在Page的继承类里使用)
回传数据处理(控件里实现了IPostBackDataHandler接口的LoadPostData方法 )
页面加载 (Load)
回传数据变化检查(控件里实现了IPostBackDataHandler接口的RaisePostDataChangedEvent方法)
回传事件处理(控件里定义的回传事件.控件里实现了IPostBackEventHandler接口的RaisePostBackEvent方法)
页面预返回阶段(PreRender,SaveViewState)
页面返回阶段(Render)
页面卸载阶段(Unload)
ProcessRequest方法最先调用的是其所在类(Page)重载实现的基类System.Web.WebControls.TemplateControl的"FrameworkInitialize”虚拟方法,页面的控件树就在这个时候产生。
浙公网安备 33010602011771号