WEB页面自打开的响应顺序
WEB页面自打开,在你按下按钮之前,会有如下响应依次发生:
private int i = 1;
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
Response.Write(i++);
Response.Write("<br />");
}
protected override void OnPreLoad(EventArgs e)
{
base.OnPreLoad(e);
Response.Write(i++);
Response.Write("<br />");
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Response.Write(i++);
Response.Write("<br />");
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Response.Write(i++);
Response.Write("<br />");
}
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
Response.Write(i++);
Response.Write("<br />");
}
protected override void OnPreLoad(EventArgs e)
{
base.OnPreLoad(e);
Response.Write(i++);
Response.Write("<br />");
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Response.Write(i++);
Response.Write("<br />");
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Response.Write(i++);
Response.Write("<br />");
}
当然,在你按下按钮之后自然是按钮响应,然后还会有一个响应发生:
按钮响应结束后,还会有一个响应发生:
protected override void OnLoadComplete(EventArgs e)
{
base.OnLoadComplete(e);
Response.Write(i++);
Response.Write("<br />");
}
{
base.OnLoadComplete(e);
Response.Write(i++);
Response.Write("<br />");
}
这样,当你页面全部打开后,页面的左上角会依次显示“1,2,3,4,5”,也即是这五个响应。
刚才查了一下,其实全部的响应如下:
1FrameworkInitialize
2InitializeCulture
3OnPreInit
4OnInit
5TrackViewState
6OnInitComplete
7OnPreLoad
8OnLoad
9Page_Load
10OnLoadComplete
11EnsureChildControls
12CreateChildControls
13OnPreRender
14OnPreRenderComplete
15OnSaveStateComplete
16RenderControl
17Render
18RenderChildren
2InitializeCulture
3OnPreInit
4OnInit
5TrackViewState
6OnInitComplete
7OnPreLoad
8OnLoad
9Page_Load
10OnLoadComplete
11EnsureChildControls
12CreateChildControls
13OnPreRender
14OnPreRenderComplete
15OnSaveStateComplete
16RenderControl
17Render
18RenderChildren