Hopes

          Start Here..

           

          關于asp.net中頁面事件加載的先后順序

          Page 執(zhí)行中將按照如下順序激活事件:

          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,那么,各事件的執(zhí)行順序將變成:

          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

          瀏覽下來發(fā)現并不是我現在所學的asp.net 1.1,估計應該是asp.net 2.0,

          不過也沒有關系,這讓我知道了他們有繼承時加載的順序。

          即:先加載繼承頁的,在加載自己的,如果繼承頁有繼承則先加載繼承頁的繼承。

          其實是個很簡單的內容。順便寫下Page事件(不知道1.1是不是就這些)

           事件處理器名稱

           發(fā)生時間

           Page_Init

          在Web窗體的視圖狀態(tài)加載服務器控件并對其初始化。

          這是web窗體生命周期的第一步 

           Page_Load

          在Page對象上載入服務器控件。由于此時視圖狀態(tài)信息是可以使用的,

          因此載這里可以用代碼來改變空間的設置或者載頁面上顯示文本。 

          Page_PreRender 應用程序將要呈現Page對象 
          Page_Unload 頁面從內存中卸載 
           Page_Error 發(fā)生未處理的異常
          Page_AbortTransaction 事務處理被終止 
          Page_CommitTransaction 事務處理被接受 
          Page_DataBinding 把頁面上的服務器空間和數據源綁定載一起 
           Page_DisposedPage對象從內存中釋放掉。這是Page對象生命周期中的最后一個事件 

          posted on 2012-08-12 14:01 ** 閱讀(426) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網站導航:
           

          導航

          統計

          公告

          你好!

          常用鏈接

          留言簿(2)

          隨筆檔案

          文章分類

          文章檔案

          新聞檔案

          相冊

          收藏夾

          C#學習

          友情鏈接

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 新宾| 和政县| 宝山区| 比如县| 荣成市| 共和县| 玛多县| 长葛市| 虹口区| 凤阳县| 云南省| 通渭县| 徐水县| 本溪市| 新干县| 大竹县| 富源县| 万安县| 宁陵县| 中西区| 青铜峡市| 乐亭县| 牡丹江市| 诸暨市| 蚌埠市| 庄浪县| 九寨沟县| 江永县| 冷水江市| 交口县| 东平县| 西畴县| 兴化市| 金秀| 南乐县| 渝北区| 泗洪县| 云和县| 枣庄市| 宜川县| 农安县|