ASP.NET 页面事件执行顺序
生活随笔
收集整理的這篇文章主要介紹了
ASP.NET 页面事件执行顺序
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2009-12-02 09:59:58|??分類: 、C Sharp| |??標簽: |字號大中小?訂閱
在作完上圖后,無意中看到網上類似的一篇文章,也非常精彩,轉載在下面供大家參考。申明,以下內容為轉載,因某些原因作者和出處無法考證,本文作者不享有以下內容的版權。
Page 執行中將按照如下順序激活事件:
Page.PreInit
Page.Init
Page.InitComplite
Page.PreLoad
Page.Load
Page.LoadComplete
Page.PreRender
Page.PreRenderComplete
如果頁面從令一個頁面繼承,如BasePage:System.Web.UI.Page,在BasePage中做了一些擴展,如權限檢查,而其他頁面從BasePage繼承,則BasePage和最終Page的事件激活順序是:
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
如果使用了MasterPage,則MasterPage中的事件和ContentPage中的事件按照下面順序激活:
ContentPage.PreInit
Master.Init
ContentPage.Init
ContentPage.InitComplite
ContentPage.PreLoad
ContentPage.Load
Master.Load
ContentPage.LoadComplete
ContentPage.PreRender
Master.PreRender
ContentPage.PreRenderComplete
更進一步,如果ContentPage繼承BasePage,那么,各事件的執行順序將變成:
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
?
MasterPage.master UserControl_OnTop.ascx Page.aspx UserControl_InPage.ascx UserControl_OnButtom.ascx| MasterPage | UserControlOnTop | Page | UserControlInPage | UserControlOnButtom |
| ? | Init | ? | ? | ? |
| ? | ? | ? | Init | ? |
| ? | ? | ? | ? | Init |
| Init | ? | ? | ? | ? |
| ? | ? | Init | ? | ? |
| ? | ? | Load | ? | ? |
| Load | ? | ? | ? | ? |
| ? | Load | ? | ? | ? |
| ? | ? | ? | Lod | ? |
| ? | ? | ? | ? | Load |
| ControlEvents | ControlEvents | ControlEvents | ControlEvents | ControlEvents |
| ? | ? | PreRender | ? | ? |
| PreRender | ? | ? | ? | ? |
| ? | PreRender | ? | ? | ? |
| ? | ? | ? | PreRender | ? |
| ? | ? | ? | ? | PreRender |
| ? | UnLoad | ? | ? | ? |
| ? | ? | ? | UnLoad | ? |
| ? | ? | ? | ? | UnLoad |
| UnLoad | ? | ? | ? | ? |
| ? | ? | UnLoad | ? | ? |
轉載于:https://www.cnblogs.com/gaoxuzhao/archive/2012/01/31/2333208.html
總結
以上是生活随笔為你收集整理的ASP.NET 页面事件执行顺序的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Visual Studio 扩展包(.v
- 下一篇: Microsoft .NET Pet S