同桌上课用手指进去了好爽_欧美丰满熟妇xxⅹⅹ性大i_成人av天天日天天拍拍_猛男gay帅男gay男男同志_欧美va天堂在线观看_人妻无码av中文系列三里桃花_亚欧免费无码在线观看_久久久精品国产亚洲av水_日韩在线免费看污污污_2021无码专区人妻系列日韩

首頁(yè) 優(yōu)化推廣 ASP.NET頁(yè)面事件執(zhí)行順序

ASP.NET頁(yè)面事件執(zhí)行順序

來源: | 時(shí)間:2011/3/29 10:13:30 |

默認(rèn)的aspx頁(yè)面都是繼承自System.Web.UI.Page,Page基類定義了很多需要預(yù)執(zhí)行的事件,這些事件雖沒有在aspx頁(yè)面中顯示的定義或提及,但它們?nèi)匀粫?huì)以一定的順序去執(zhí)行,這些事件的執(zhí)行順序是:

1. OnPreInit
2. OnInit
3. OnInitComplete
4. OnPreLoad
5. Page_Load
6. OnLoad
7. OnLoadComplete
8. OnPreRender
9. OnPreRenderComplete

 以上事件除了Page_Load 為aspx頁(yè)面自己的事件外,其余的都是繼承自基類Page。

當(dāng)頁(yè)面進(jìn)行回發(fā)時(shí),如點(diǎn)擊按鈕,以上事件都會(huì)重新執(zhí)行一次,這時(shí)的執(zhí)行順序?yàn)椋?/p>

1. OnPreInit
2. OnInit
3. OnInitComplete
4. OnPreLoad
5. Page_Load
6. OnLoad

7. Button_Click

8. OnLoadComplete
9. OnPreRender
10. OnPreRenderComplete

可以看到,Button_Click事件位于OnLoad之后執(zhí)行;
可以測(cè)試一下:

public partial class TestControls : System.Web.UI.Page
    {
        static int count = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(count+ "Page_Load <br />");
            count++;
        }
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            Response.Write(count + "OnPreInit <br />");
            count++;
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            Response.Write(count + "OnInit <br />");
            count++;
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Response.Write(count + "OnLoad <br />");
            count++;
        }
        protected override void OnPreLoad(EventArgs e)
        {
            base.OnPreLoad(e);
            Response.Write(count + "OnPreLoad <br />");
            count++;
        }
        protected override void OnLoadComplete(EventArgs e)
        {
            base.OnLoadComplete(e);
            Response.Write(count + "OnLoadComplete <br />");
            count++;
        }
        protected override void OnInitComplete(EventArgs e)
        {
            base.OnInitComplete(e);
            Response.Write(count + "OnInitComplete <br />");
            count++;
        }
        protected override void OnUnload(EventArgs e)
        {
            base.OnUnload(e);
        }
        protected override void OnDataBinding(EventArgs e)
        {
            base.OnDataBinding(e);
            Response.Write(count + "OnDataBinding <br />");
            count++;
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            Response.Write(count + "OnPreRender <br />");
            count++;
        }

        protected void btnGraphics_Click(object sender, EventArgs e)
        {
            //Bitmap bmp = new Bitmap(10, 10);
            //Graphics g = Graphics.FromImage(bmp);
            Response.Write(count + "btnGraphics_Click <br />");
            count++;
        }
    }

服務(wù)熱線

153 8323 9821

功能和特性

價(jià)格和優(yōu)惠

網(wǎng)站和維護(hù)

推廣和優(yōu)化

微信服務(wù)號(hào)