|
------------------------测试窗体页事件顺序,代码如下-------------------------
protected void Page_PreInit(object sender,EventArgs e)
{
string s = DateTime.Now.ToLongTimeString();
s += "事件名称为Page_PreInit";
Response.Write(s);
Response.Write("<br />");
System.Threading.Thread.Sleep(1000);
}
/// <summary>
/// 窗体页初始化
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Init(object sender,EventArgs e)
{
string s = DateTime.Now.ToLongTimeString();
s += "事件名称为Page_Init";
Response.Write(s);
Response.Write("<br />");
System.Threading.Thread.Sleep(1000);
}
/// <summary>
/// 窗体页初始化完成
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_InitComplete(object sender, EventArgs e)
{
string s = DateTime.Now.ToLongTimeString();
s += "事件名称为Page_InitComplete";
Response.Write(s);
Response.Write("<br />");
System.Threading.Thread.Sleep(1000);
}
/// <summary>
/// 窗体页预加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_PreLoad(object sender, EventArgs e)
{
string s = DateTime.Now.ToLongTimeString();
s += "事件名称为Page_PreLoad";
Response.Write(s);
Response.Write("<br />");
System.Threading.Thread.Sleep(1000);
}
/// <summary>
/// 窗体页加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
string s = DateTime.Now.ToLongTimeString();
s += "事件名称为Page_Load";
Response.Write(s);
Response.Write("<br />");
System.Threading.Thread.Sleep(1000);
}
/// <summary>
/// 窗体页加载完成
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_LoadComplete(object sender, EventArgs e)
{
string s = DateTime.Now.ToLongTimeString();
s += "事件名称为Page_LoadComplete";
Response.Write(s);
Response.Write("<br />");
System.Threading.Thread.Sleep(1000);
}
/// <summary>
/// 窗体页渲染前
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_PreRender(object sender, EventArgs e)
{
string s = DateTime.Now.ToLongTimeString();
s += "事件名称为Page_PreRender";
Response.Write(s);
Response.Write("<br />");
System.Threading.Thread.Sleep(1000);
}
/// <summary>
///窗体页保存视图状态
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_SaveStateComplete(object sender, EventArgs e)
{
string s = DateTime.Now.ToLongTimeString();
s += "事件名称为Page_SaveStateComplete";
Response.Write(s);
Response.Write("<br />");
System.Threading.Thread.Sleep(1000);
}
/// <summary>
/// 窗体页渲染
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Render(object sender, EventArgs e)
{
string s = DateTime.Now.ToLongTimeString();
s += "事件名称为Page_Render";
Response.Write(s);
Response.Write("<br />");
System.Threading.Thread.Sleep(1000);
}
/// <summary>
/// 窗体页卸载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Unload(object sender, EventArgs e)
{
string s = DateTime.Now.ToLongTimeString();
s += "事件名称为Page_Unload";
ApplicationInstance.Response.Write(s);
ApplicationInstance.Response.Write("<br />");
System.Threading.Thread.Sleep(1000);
}
------------------------输出结果如下-------------------------
20:56:29事件名称为Page_PreInit
20:56:30事件名称为Page_Init
20:56:31事件名称为Page_InitComplete
20:56:32事件名称为Page_PreLoad
20:56:33事件名称为Page_Load
20:56:34事件名称为Page_LoadComplete
20:56:35事件名称为Page_PreRender
20:56:36事件名称为Page_SaveStateComplete
20:56:37事件名称为Page_Unload
注意上面空一行,为Page_Render事件没有显示。请问为什么? |
|