UpdatePanel控件使用详解(二)
摘要:当最外面的UpdatePanel被触发更新时,它里面的子UpdatePanel也随着更新,里面的UpdatePanel触发更新时,只更新它自己,而不会更新外层的UpdatePanel。看下面的例子:123456789
用编程的方法控制UpdatePanel的更新
于UpdatePanel,我们也可以使用编程的方法来控制它的更新,可以通过ScriptManager的RegisterAsyncPostBackControl()方法注册一个异步提交的控件,并且调用UpdatePanel的Update()方法来让它更新。再次用我在前面的文章中用到的一个无聊的时间更新例子来看一下,有时候我觉得例子过于复杂更加不好说明白所要讲的内容,如下代码所示,注意Button1并不包含在UpdatePanel中:
![UpdatePanel控件使用详解(二)第1张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![UpdatePanel控件使用详解(二)第2张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
1![UpdatePanel控件使用详解(二)第3张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%>2![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3![UpdatePanel控件使用详解(二)第3张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<scriptrunat="server">
4![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
voidButton1_Click(objectsender,EventArgse)
6![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
8![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
this.Label2.Text=DateTime.Now.ToString();
10![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
}12![UpdatePanel控件使用详解(二)第20张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
13
</script>14![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
<htmlxmlns="http://www.w3.org/1999/xhtml">16![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
17
<headrunat="server">18![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
19
<title>RefreshinganUpdatePanelProgrammatically</title>20![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
21
</head>22![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
23
<body>24![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
25
<formid="form1"runat="server">26![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
27
<asp:ScriptManagerID="ScriptManager1"runat="server"/>28![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
29
<div>30![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
<asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional">32![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
33
<ContentTemplate>34![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
35
<asp:LabelID="Label1"runat="server"Text="更新时间:"></asp:Label>36![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
37
<asp:LabelID="Label2"runat="server"Text="Label"ForeColor="Red"></asp:Label><br/><br/>38![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
39![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
40![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
41
</ContentTemplate>42![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
43
</asp:UpdatePanel>44![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
45
<asp:ButtonID="Button1"runat="server"Text="Button"OnClick="Button1_Click"/>46![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
47
</div>48![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
49
</form>50![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
51
</body>52![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
53
</html> 这时候不用多说,肯定是整页提交了,运行如下图所示:
再次修改上面的例子,使用ScriptManager的RegisterAsyncPostBackControl()注册Button1为一个异步提交控件,并且调用UpdatePanel的Update()方法:
![UpdatePanel控件使用详解(二)第63张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![UpdatePanel控件使用详解(二)第64张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
1![UpdatePanel控件使用详解(二)第3张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%>2![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3![UpdatePanel控件使用详解(二)第3张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<scriptrunat="server">
4![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
voidPage_Load(objectsender,EventArgse)
6![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
8![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
ScriptManager1.RegisterAsyncPostBackControl(Button1);
10![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
}12![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
voidButton1_Click(objectsender,EventArgse)
16![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
18![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
this.Label2.Text=DateTime.Now.ToString();
20![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
this.UpdatePanel1.Update();
22![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
}24![UpdatePanel控件使用详解(二)第20张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
25
</script>26![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
27
<htmlxmlns="http://www.w3.org/1999/xhtml">28![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
29
<headrunat="server">30![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
<title>RefreshinganUpdatePanelProgrammatically</title>32![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
33
</head>34![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
35
<body>36![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
37
<formid="form1"runat="server">38![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
39
<asp:ScriptManagerID="ScriptManager1"runat="server"/>40![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
41
<div>42![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
43
<asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional">44![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
45
<ContentTemplate>46![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
47
<asp:LabelID="Label1"runat="server"Text="更新时间:"></asp:Label>48![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
49
<asp:LabelID="Label2"runat="server"Text="Label"ForeColor="Red"></asp:Label><br/><br/>50![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
51![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
52![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
53
</ContentTemplate>54![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
55
</asp:UpdatePanel>56![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
57
<asp:ButtonID="Button1"runat="server"Text="Button"OnClick="Button1_Click"/>58![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
59
</div>60![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
61
</form>62![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
63
</body>64![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
65
</html>这时候可以看到,已经是异步提交了:
![UpdatePanel控件使用详解(二)第138张](https://www.cnblogs.com/images/cnblogs_com/terrylee/ASPNETAJAX_010.gif)
UpdatePanel的嵌套使用
UpdatePanel还可以嵌套使用,即在一个UpdatePanel的ContentTemplate中还可以放入另一个UpdatePanel。当最外面的UpdatePanel被触发更新时,它里面的子UpdatePanel也随着更新,里面的UpdatePanel触发更新时,只更新它自己,而不会更新外层的UpdatePanel。看下面的例子:
![UpdatePanel控件使用详解(二)第139张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![UpdatePanel控件使用详解(二)第140张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
1![UpdatePanel控件使用详解(二)第3张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default2.aspx.cs"Inherits="Default2"%>2![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3![UpdatePanel控件使用详解(二)第3张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<scriptrunat="server">
4![UpdatePanel控件使用详解(二)第20张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
5
</script>6![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
<htmlxmlns="http://www.w3.org/1999/xhtml">10![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
<headid="Head1"runat="server">12![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
<title>UpdatePanelUpdateModeExample</title>14![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15![UpdatePanel控件使用详解(二)第3张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<styletype="text/css">
16![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
div.NestedPanel
18![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
}{}{
}{20![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
position:relative;22![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
margin:2%5%2%5%;24![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
25
}26![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
</style>28![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
29
</head>30![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
<body>32![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
33
<formid="form1"runat="server">34![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
35
<div>36![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
37
<asp:ScriptManagerID="ScriptManager"38![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
39
runat="server"/>40![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
41
<asp:UpdatePanelID="OuterPanel"42![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
43
UpdateMode="Conditional"44![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
45
runat="server">46![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
47
<ContentTemplate>48![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
49
<div>50![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
51
<fieldset>52![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
53
<legend>OuterPanel</legend>54![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
55
<br/>56![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
57
<asp:ButtonID="OPButton1"58![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
59
Text="OuterPanelButton"60![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
61
runat="server"/>62![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
63
<br/>64![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
65
Lastupdatedon
66![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
67
<%=DateTime.Now.ToString()%>68![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
69
<br/>70![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
71
<br/>72![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
73
<asp:UpdatePanelID="NestedPanel1"74![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
75
UpdateMode="Conditional"76![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
77
runat="server">78![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
79
<ContentTemplate>80![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
81
<divclass="NestedPanel">82![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
83
<fieldset>84![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
85
<legend>NestedPanel1</legend>86![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
87
<br/>88![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
89
Lastupdatedon
90![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
91
<%=DateTime.Now.ToString()%>92![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
93
<br/>94![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
95
<asp:ButtonID="NPButton1"96![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
97
Text="NestedPanel1Button"98![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
99
runat="server"/>100![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
101
</fieldset>102![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
103
</div>104![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
105
</ContentTemplate>106![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
107
</asp:UpdatePanel>108![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
109
</fieldset>110![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
111
</div>112![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
113
</ContentTemplate>114![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
115
</asp:UpdatePanel>116![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
117
</div>118![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
119
</form>120![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
121
</body>122![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
123
</html> 运行后如下:![UpdatePanel控件使用详解(二)第273张](https://www.cnblogs.com/images/cnblogs_com/terrylee/ASPNETAJAX_012.gif)
同一页面上使用多个UpdatePanel使用UpdatePanel的时候并没有限制在一个页面上用多少个UpdatePanel,所以我们可以为不同的需要局部更新的页面区域加上不同的UpdatePanel。由于UpdatePanel默认的UpdateMode是Always,如果页面上有一个局部更新被触发,则所有的UpdatePanel都将更新,这是我们不愿看到的,我们只需要UpdatePanel在它自己的触发器触发的时候更新就可以了,所以需要把UpdateMode设置为Conditional。
来看一下官方网站上提供的一个例子:包括两个UpdatePanel,其中一个用来用户输入而另一个则用来显示数据,每一个UpdatePanel的UpdateMode属性都设置为Conditional。当我们单击Cancel按钮时,只有用来用户输入的那个UpdatePanel刷新,当单击Insert按钮时,两个UpdatePanel都刷新。代码如下:
![UpdatePanel控件使用详解(二)第274张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![UpdatePanel控件使用详解(二)第275张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
1![UpdatePanel控件使用详解(二)第3张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
@PageLanguage="C#"%>2![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3![UpdatePanel控件使用详解(二)第3张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<%
@ImportNamespace="System.Collections.Generic"%>4![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
<htmlxmlns="http://www.w3.org/1999/xhtml">8![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
<headid="Head1"runat="server">10![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
<title>EnterNewEmployees</title>12![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13![UpdatePanel控件使用详解(二)第3张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<scriptrunat="server">
14![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
privateList<Employee>EmployeeList;
16![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
protectedvoidPage_Load()
20![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
22![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
if(!IsPostBack)
24![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
25![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
26![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
EmployeeList=newList<Employee>();
28![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
EmployeeList.Add(newEmployee(1,"Jump","Dan"));
30![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
31
EmployeeList.Add(newEmployee(2,"Kirwan","Yvette"));
32![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
33
ViewState["EmployeeList"]=EmployeeList;
34![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
35
}36![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
37
else38![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
39
EmployeeList=(List<Employee>)ViewState["EmployeeList"];
40![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
41![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
42![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
43
EmployeesGridView.DataSource=EmployeeList;
44![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
45
EmployeesGridView.DataBind();
46![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
47
}48![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
49![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
50![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
51
protectedvoidInsertButton_Click(objectsender,EventArgse)
52![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
53![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
54![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
55
if(String.IsNullOrEmpty(FirstNameTextBox.Text)||56![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
57![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
String.IsNullOrEmpty(LastNameTextBox.Text))
{return;}58![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
59![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
60![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
61
intemployeeID=EmployeeList[EmployeeList.Count-1].EmployeeID+1;
62![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
63![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
64![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
65
stringlastName=Server.HtmlEncode(FirstNameTextBox.Text);
66![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
67
stringfirstName=Server.HtmlEncode(LastNameTextBox.Text);
68![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
69![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
70![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
71
FirstNameTextBox.Text=String.Empty;
72![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
73
LastNameTextBox.Text=String.Empty;
74![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
75![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
76![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
77
EmployeeList.Add(newEmployee(employeeID,lastName,firstName));
78![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
79
ViewState["EmployeeList"]=EmployeeList;
80![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
81![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
82![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
83
EmployeesGridView.DataBind();
84![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
85
EmployeesGridView.PageIndex=EmployeesGridView.PageCount;
86![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
87
}88![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
89![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
90![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
91
protectedvoidCancelButton_Click(objectsender,EventArgse)
92![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
93![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
94![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
95
FirstNameTextBox.Text=String.Empty;
96![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
97
LastNameTextBox.Text=String.Empty;
98![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
99
}100![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
101![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
102![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
103
[Serializable]
104![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
105
publicclassEmployee
106![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
107![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
108![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
109
privateint_employeeID;
110![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
111
privatestring_lastName;
112![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
113
privatestring_firstName;
114![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
115![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
116![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
117
publicintEmployeeID
118![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
119![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
120![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
121![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{return_employeeID;}122![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
123
}124![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
125![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
126![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
127
publicstringLastName
128![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
129![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
130![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
131![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{return_lastName;}132![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
133
}134![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
135![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
136![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
137
publicstringFirstName
138![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
139![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
140![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
141![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
get
{return_firstName;}142![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
143
}144![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
145![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
146![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
147
publicEmployee(intemployeeID,stringlastName,stringfirstName)
148![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
149![UpdatePanel控件使用详解(二)第13张](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![UpdatePanel控件使用详解(二)第14张](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
{
150![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
151
_employeeID=employeeID;
152![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
153
_lastName=lastName;
154![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
155
_firstName=firstName;
156![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
157
}158![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
159
}160![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
161![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
162![UpdatePanel控件使用详解(二)第10张](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
163
</script>164![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
165
</head>166![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
167
<body>168![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
169
<formid="form1"runat="server">170![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
171
<div>172![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
173
</div>174![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
175
<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/>176![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
177
<table>178![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
179
<tr>180![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
181
<tdstyle="height:206px"valign="top">182![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
183
<asp:UpdatePanelID="InsertEmployeeUpdatePanel"runat="server"UpdateMode="Conditional">184![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
185
<ContentTemplate>186![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
187
<tablecellpadding="2"border="0"style="background-color:#7C6F57">188![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
189
<tr>190![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
191
<td><asp:LabelID="FirstNameLabel"runat="server"AssociatedControlID="FirstNameTextBox"192![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
193
Text="FirstName"ForeColor="White"/></td>194![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
195
<td><asp:TextBoxrunat="server"ID="FirstNameTextBox"/></td>196![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
197
</tr>198![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
199
<tr>200![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
201
<td><asp:LabelID="LastNameLabel"runat="server"AssociatedControlID="LastNameTextBox"202![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
203
Text="LastName"ForeColor="White"/></td>204![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
205
<td><asp:TextBoxrunat="server"ID="LastNameTextBox"/></td>206![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
207
</tr>208![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
209
<tr>210![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
211
<td></td>212![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
213
<td>214![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
215
<asp:LinkButtonID="InsertButton"runat="server"Text="Insert"OnClick="InsertButton_Click"ForeColor="White"/>216![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
217
<asp:LinkButtonID="Cancelbutton"runat="server"Text="Cancel"OnClick="CancelButton_Click"ForeColor="White"/>218![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
219
</td>220![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
221
</tr>222![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
223
</table>224![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
225
<asp:Labelrunat="server"ID="InputTimeLabel"><%=DateTime.Now%></asp:Label>226![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
227
</ContentTemplate>228![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
229
</asp:UpdatePanel>230![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
231
</td>232![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
233
<tdstyle="height:206px"valign="top">234![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
235
<asp:UpdatePanelID="EmployeesUpdatePanel"runat="server"UpdateMode="Conditional">236![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
237
<ContentTemplate>238![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
239
<asp:GridViewID="EmployeesGridView"runat="server"BackColor="LightGoldenrodYellow"BorderColor="Tan"240![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
241
BorderWidth="1px"CellPadding="2"ForeColor="Black"GridLines="None"AutoGenerateColumns="False">242![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
243
<FooterStyleBackColor="Tan"/>244![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
245
<SelectedRowStyleBackColor="DarkSlateBlue"ForeColor="GhostWhite"/>246![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
247
<PagerStyleBackColor="PaleGoldenrod"ForeColor="DarkSlateBlue"HorizontalAlign="Center"/>248![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
249
<HeaderStyleBackColor="Tan"Font-Bold="True"/>250![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
251
<AlternatingRowStyleBackColor="PaleGoldenrod"/>252![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
253
<Columns>254![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
255
<asp:BoundFieldDataField="EmployeeID"HeaderText="EmployeeID"/>256![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
257
<asp:BoundFieldDataField="LastName"HeaderText="LastName"/>258![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
259
<asp:BoundFieldDataField="FirstName"HeaderText="FirstName"/>260![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
261
</Columns>262![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
263
<PagerSettingsPageButtonCount="5"/>264![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
265
</asp:GridView>266![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
267
<asp:Labelrunat="server"ID="ListTimeLabel"><%=DateTime.Now%></asp:Label>268![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
269
</ContentTemplate>270![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
271
<Triggers>272![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
273
<asp:AsyncPostBackTriggerControlID="InsertButton"EventName="Click"/>274![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
275
</Triggers>276![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
277
</asp:UpdatePanel>278![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
279
</td>280![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
281
</tr>282![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
283
</table>284![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
285
</form>286![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
287
</body>288![UpdatePanel控件使用详解(二)第6张](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
289
</html>运行后效果如下:
![UpdatePanel控件使用详解(二)第597张](https://www.cnblogs.com/images/cnblogs_com/terrylee/ASPNETAJAX_011.gif)
转自:http://www.cnblogs.com/Terrylee/archive/2006/11/01/ASPNET_AJAX_UpdatePanle_Part2.html
示例代码下载:https://files.cnblogs.com/Terrylee/ASPNETAJAXUpdatePanelDemo2.rar
免责声明:文章转载自《UpdatePanel控件使用详解(二)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。
上篇使用Advanced Installer制作IIS安装包(二:配置安装包依赖项和自定义dll)一些常用的dos命令下篇
宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=
一、什么是Bean Shell BeanShell是一种完全符合Java语法规范的脚本语言,并且又拥有自己的一些语法和方法; BeanShell是一种松散类型的脚本语言(这点和JS类似); BeanShell是用Java写成的,一个小型的、免费的、可以下载的、嵌入式的Java源代码解释器,具有对象脚本语言特性,非常精简的解释器jar文件大小为175k。...