页面的生存周期
以上是一个页面运用了模板页并且在页面中使用了用户控件
在页面中添加以下代码
Code
1 protected void Page_PreInit(object sender, EventArgs e)
2 {
3 Response.Write("Page_PreInit<br/>");
4 }
5 protected void Page_Init(object sender, EventArgs e)
6 {
7 Response.Write("Page_Init<br/>");
8 }
9 protected void Page_InitComplete(object sender, EventArgs e)
10 {
11 Response.Write("Page_InitComplete<br/>");
12 }
13 protected void Page_PreLoad(object sender, EventArgs e)
14 {
15 Response.Write("Page_PreLoad<br/>");
16 }
17 protected void Page_Load(object sender, EventArgs e)
18 {
19 Response.Write("Page_Load<br/>");
20 }
21 protected void Page_LoadComplete(object sender, EventArgs e)
22 {
23 Response.Write("Page_LoadComplete<br/>");
24 }
25 protected void Page_PreRender(object sender, EventArgs e)
26 {
27 Response.Write("Page_PreRender<br/>");
28 }
29 protected void Page_PreRenderComplete(object sender, EventArgs e)
30 {
31 Response.Write("Page_PreRenderComplete<br/>");
32 }
33 protected void Page_SaveStateComplete(object sender, EventArgs e)
34 {
35 Response.Write("Page_SaveStateComplete<br/>");
36 }
37 protected void Page_Unload(object sender, EventArgs e)
38 {
39 //Response.Write("Page_Unload<br/>");
40 int i = 0;
41 i++;//这行代码是用来设置断点的,这里不能用Response.Write
42 }
43
44
45 protected void Button2_Click(object sender, EventArgs e)
46 {
47 Response.Write("Button事件触发!<br/>");
48 }
1 protected void Page_PreInit(object sender, EventArgs e)
2 {
3 Response.Write("Page_PreInit<br/>");
4 }
5 protected void Page_Init(object sender, EventArgs e)
6 {
7 Response.Write("Page_Init<br/>");
8 }
9 protected void Page_InitComplete(object sender, EventArgs e)
10 {
11 Response.Write("Page_InitComplete<br/>");
12 }
13 protected void Page_PreLoad(object sender, EventArgs e)
14 {
15 Response.Write("Page_PreLoad<br/>");
16 }
17 protected void Page_Load(object sender, EventArgs e)
18 {
19 Response.Write("Page_Load<br/>");
20 }
21 protected void Page_LoadComplete(object sender, EventArgs e)
22 {
23 Response.Write("Page_LoadComplete<br/>");
24 }
25 protected void Page_PreRender(object sender, EventArgs e)
26 {
27 Response.Write("Page_PreRender<br/>");
28 }
29 protected void Page_PreRenderComplete(object sender, EventArgs e)
30 {
31 Response.Write("Page_PreRenderComplete<br/>");
32 }
33 protected void Page_SaveStateComplete(object sender, EventArgs e)
34 {
35 Response.Write("Page_SaveStateComplete<br/>");
36 }
37 protected void Page_Unload(object sender, EventArgs e)
38 {
39 //Response.Write("Page_Unload<br/>");
40 int i = 0;
41 i++;//这行代码是用来设置断点的,这里不能用Response.Write
42 }
43
44
45 protected void Button2_Click(object sender, EventArgs e)
46 {
47 Response.Write("Button事件触发!<br/>");
48 }
Code
protected void Page_PreInit(object sender, EventArgs e)
{
Response.Write("MasterPage_PreInit<br/>");
}
protected void Page_Init(object sender, EventArgs e)
{
Response.Write("MasterPage_Init<br/>");
}
protected void Page_InitComplete(object sender, EventArgs e)
{
Response.Write("MasterPage_InitComplete<br/>");
}
protected void Page_PreLoad(object sender, EventArgs e)
{
Response.Write("MasterPage_PreLoad<br/>");
}
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("MasterPage_Load<br/>");
}
protected void Page_LoadComplete(object sender, EventArgs e)
{
Response.Write("MasterPage_LoadComplete<br/>");
}
protected void Page_PreRender(object sender, EventArgs e)
{
Response.Write("MasterPage_PreRender<br/>");
}
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
Response.Write("MasterPage_PreRenderComplete<br/>");
}
protected void Page_SaveStateComplete(object sender, EventArgs e)
{
Response.Write("MasterPage_SaveStateComplete<br/>");
}
protected void Page_Unload(object sender, EventArgs e)
{
//Response.Write("MasterPage_Unload<br/>");
int i = 0;
i++;//这行代码是用来设置断点的,这里不能用Response.Write
}
在用户控件中加入一下代码protected void Page_PreInit(object sender, EventArgs e)
{
Response.Write("MasterPage_PreInit<br/>");
}
protected void Page_Init(object sender, EventArgs e)
{
Response.Write("MasterPage_Init<br/>");
}
protected void Page_InitComplete(object sender, EventArgs e)
{
Response.Write("MasterPage_InitComplete<br/>");
}
protected void Page_PreLoad(object sender, EventArgs e)
{
Response.Write("MasterPage_PreLoad<br/>");
}
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("MasterPage_Load<br/>");
}
protected void Page_LoadComplete(object sender, EventArgs e)
{
Response.Write("MasterPage_LoadComplete<br/>");
}
protected void Page_PreRender(object sender, EventArgs e)
{
Response.Write("MasterPage_PreRender<br/>");
}
protected void Page_PreRenderComplete(object sender, EventArgs e)
{
Response.Write("MasterPage_PreRenderComplete<br/>");
}
protected void Page_SaveStateComplete(object sender, EventArgs e)
{
Response.Write("MasterPage_SaveStateComplete<br/>");
}
protected void Page_Unload(object sender, EventArgs e)
{
//Response.Write("MasterPage_Unload<br/>");
int i = 0;
i++;//这行代码是用来设置断点的,这里不能用Response.Write
}
Code
1 protected void Page_PreInit(object sender, EventArgs e)
2 {
3 Response.Write("UserControl_PreInit<br/>");
4 }
5 protected void Page_Init(object sender, EventArgs e)
6 {
7 Response.Write("UserControl_Init<br/>");
8 }
9 protected void Page_InitComplete(object sender, EventArgs e)
10 {
11 Response.Write("UserControl_InitComplete<br/>");
12 }
13 protected void Page_PreLoad(object sender, EventArgs e)
14 {
15 Response.Write("UserControl_PreLoad<br/>");
16 }
17 protected void Page_Load(object sender, EventArgs e)
18 {
19 Response.Write("UserControl_Load<br/>");
20 }
21 protected void Page_LoadComplete(object sender, EventArgs e)
22 {
23 Response.Write("UserControl_LoadComplete<br/>");
24 }
25 protected void Page_PreRender(object sender, EventArgs e)
26 {
27 Response.Write("UserControl_PreRender<br/>");
28 }
29 protected void Page_PreRenderComplete(object sender, EventArgs e)
30 {
31 Response.Write("UserControl_PreRenderComplete<br/>");
32 }
33 protected void Page_SaveStateComplete(object sender, EventArgs e)
34 {
35 Response.Write("UserControl_SaveStateComplete<br/>");
36 }
37 protected void Page_Unload(object sender, EventArgs e)
38 {
39 //Response.Write("MasterPage_Unload<br/>");
40 int i = 0;
41 i++;//这行代码是用来设置断点的,这里不能用Response.Write
42 }
1 protected void Page_PreInit(object sender, EventArgs e)
2 {
3 Response.Write("UserControl_PreInit<br/>");
4 }
5 protected void Page_Init(object sender, EventArgs e)
6 {
7 Response.Write("UserControl_Init<br/>");
8 }
9 protected void Page_InitComplete(object sender, EventArgs e)
10 {
11 Response.Write("UserControl_InitComplete<br/>");
12 }
13 protected void Page_PreLoad(object sender, EventArgs e)
14 {
15 Response.Write("UserControl_PreLoad<br/>");
16 }
17 protected void Page_Load(object sender, EventArgs e)
18 {
19 Response.Write("UserControl_Load<br/>");
20 }
21 protected void Page_LoadComplete(object sender, EventArgs e)
22 {
23 Response.Write("UserControl_LoadComplete<br/>");
24 }
25 protected void Page_PreRender(object sender, EventArgs e)
26 {
27 Response.Write("UserControl_PreRender<br/>");
28 }
29 protected void Page_PreRenderComplete(object sender, EventArgs e)
30 {
31 Response.Write("UserControl_PreRenderComplete<br/>");
32 }
33 protected void Page_SaveStateComplete(object sender, EventArgs e)
34 {
35 Response.Write("UserControl_SaveStateComplete<br/>");
36 }
37 protected void Page_Unload(object sender, EventArgs e)
38 {
39 //Response.Write("MasterPage_Unload<br/>");
40 int i = 0;
41 i++;//这行代码是用来设置断点的,这里不能用Response.Write
42 }