我有一段测试代码来了解事件处理程序的执行顺序。为什么顺序是这样的?:
Button1_Init
Page_Init
Page_Load
Button1_Load
Page_PreRender
Button1_PreRender
Button1_Unload
Page_Unload
例如,为什么是Button1_Init
before Page_Init
,但是Page_Load
是 before Button1_Load
?
测试代码:
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Page_PreRender(object sender, EventArgs e)
{
}
protected void Page_Disposed(object sender, EventArgs e)
{
}
protected void Page_Unload(object sender, EventArgs e)
{
}
protected void Button1_Init(object sender, EventArgs e)
{
}
protected void Button1_Load(object sender, EventArgs e)
{
}
protected void Button1_PreRender(object sender, EventArgs e)
{
}
protected void Button1_Disposed(object sender, EventArgs e)
{
}
protected void Button1_Unload(object sender, EventArgs e)
{
}
}