ASP.NET 页面生命周期
a) 页面初始化 Init
b) 加载视图状态 LoadViewState
c) 处理回发数据 任意实现 IPostBackDataHandler 接口的控件中的 LoadPostData 方法
d) 加载页面 Load
e) 回发更改通知 任意实现 IPostBackDataHandler 接口的控件中的 RaisePostDataChangedEvent 方法
f) 处理回发事件 由控件定义的任意回发事件 任意实现 IPostBackDataHandler 接口的控件中的 RaisePostBackEvent 方法
页面显示前阶段 PreRender
g) 保存视图状态 SaveViewState
h) 显示页面 Render
i) 卸载页面 Unload
protected void Page_PreInit(object sender, EventArgs e)
{
Response.Write("Page_PreInit<br/>");
}
protected void Page_Init(object sender, EventArgs e)
{
Response.Write("Page_Init<br/>");
}
protected void Page_InitComplete(object sender, EventArgs e)
{
Response.Write("Page_InitComplete<br/>");
}
protected void Page_PreLoad(object sender, EventArgs e)
{
Response.Write("Page_PreLoad<br/>");
}
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Page_Load<br/>");
}
protected void Page_LoadComplete(object sender, EventArgs e)
{
Response.Write("Page_LoadComplete<br/>");
}
protected void Page_PreRender(object sender, EventArgs e)
{
Response.Write("Page_PreRender<br/>");
}
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
Response.Write("Page_PreRenderComplete<br/>");
}
protected void Page_SaveStateComplete(object sender, EventArgs e)
{
Response.Write("Page_SaveStateComplete<br/>");
}
protected void Page_Unload(object sender, EventArgs e)
{
//Response.Write("Page_Unload<br/>");
int i = 0;
i++;//这行代码是用来设置断点的,这里不能用Response.Write
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("Button事件触发!<br/>");
}