记录ASPX页面的加载及卸载顺序

Default1:正常的Page(包含:uc1用户控件)
MasterPage1:模板页面(包含:uc2用户控件)
一、服务器端的初始化前:
         1、Default1的Page_PreInit
二、服务器端的初始化:
         1、Default1中的uc1的Page_Init
         2、MasterPage1中的uc2的Page_Init
         3、MasterPage1的Page_Init
         4、Default1的Page_Init
三、服务器端的初始化完成:
         1、Default1的Page_InitComplete
四、服务器端的加载之前:
         1、Default1的Page_PreLoad
五、服务器端的加载:
         1、Default1的Page_Load
         2、MasterPage1的Page_Load
         3、Default1的的uc1的Page_Load
         4、MasterPage1的uc2的Page_Load
六、服务器端的加载完成:
         1、Default1的Page_LoadComplete
七、服务器端的渲染之前:
         1、Default1的Page_PreRender
         2、MasterPage1的Page_PreRender
         3、Default1的的uc1的Page_PreRender
         4、MasterPage1的uc2的Page_PreRender
八、服务器端的渲染完成之前:
         1、Default1的Page_PreRenderComplete
九、服务器端完成保存状态:
         1、Default1的Page_SaveStateComplete
十、服务器端卸载:
         1、Default1的的uc1的Page_Unload
         2、MasterPage1的uc2的Page_Unload
         3、MasterPage1的Page_Unload
         4、Default1的Page_Unload
 
说明:经过一下代码测试得到结果,在每个页面上加上一下代码。
               如果有些只是一点的话,这说明该事件只有该对象才有。
 
       protected void Page_Load(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_Load");
       }
       protected void Page_Unload(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_Unload");
       }
       protected void Page_SaveStateComplete(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_SaveStateComplete");
       }
       protected void Page_PreRenderComplete(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_PreRenderComplete");
       }
       protected void Page_PreRender(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_PreRender");
       }
       protected void Page_PreLoad(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_PreLoad");
       }
       protected void Page_PreInit(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_PreInit");
       }
       protected void Page_LoadComplete(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_LoadComplete");
       }
       protected void Page_InitComplete(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_InitComplete");
       }
       protected void Page_Init(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_Init");
       }
       protected void Page_Error(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_Error");
       }
       protected void Page_Disposed(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_Disposed");
       }
       protected void Page_DataBinding(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_DataBinding");
       }
       protected void Page_CommitTransaction(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_CommitTransaction");
       }
       protected void Page_AbortTransaction(object sender, EventArgs e)
       {
               DoIndex();
               System.Diagnostics.Debug.WriteLine(Session["index"].ToString() + " 、 " + this.ToString() + " : Page_AbortTransaction");
       }
       private void DoIndex()
       {
               if (Session["index"] == null)
               {
                       Session["index"] = 1;
               }
               else
               {
                       string strIndex = Session["index"].ToString();
                       int index = Convert.ToInt32(strIndex);
                       index = index + 1;
                       Session["index"] = index;
               }
       }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值