继续章立民asp.net ajax 168范例的读书笔记
1) 比如有两个updatepannel1和updatepannel2,如果要在updatepannel1中点按钮,去更新updatepannel2中的内容,但updatepanel1中的内容不变,其主要设置好各updatepannel的childrenastriggers属性为false,以及updatemode属性为conditional即可
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<table border="1" style="width: 440px">
<tr>
<td valign="top" style="width: 100px; height: 13px">
<asp:Panel ID="Panel1" runat="server" Height="120px" Width="320px" GroupingText="UpdatePanel1">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
<ContentTemplate>
<br />
<asp:Button ID="Button1" runat="server" Text="异步局部更新 UpdatePanel2" />
<br />
<%=DateTime.Now.ToString()%>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<br />
</asp:Panel>
</td>
<td valign="top" style="width: 100px; height: 13px">
<asp:Panel ID="Panel2" runat="server" Height="176px" Width="320px" GroupingText="UpdatePanel2">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
<ContentTemplate>
<br />
<asp:Button ID="Button2" runat="server" Text="异步局部更新 UpdatePanel1" />
<br />
<%=DateTime.Now.ToString()%>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<br />
</asp:Panel>
</td>
</tr>
</table>
</form>
2 如果一个上传控件fileupload放在updatepannel中,由于其不兼容updatepannel,所以必须在triggers属性中添加postbacktrigger触发器,以说明是引发全局更新
1) 比如有两个updatepannel1和updatepannel2,如果要在updatepannel1中点按钮,去更新updatepannel2中的内容,但updatepanel1中的内容不变,其主要设置好各updatepannel的childrenastriggers属性为false,以及updatemode属性为conditional即可
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<table border="1" style="width: 440px">
<tr>
<td valign="top" style="width: 100px; height: 13px">
<asp:Panel ID="Panel1" runat="server" Height="120px" Width="320px" GroupingText="UpdatePanel1">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
<ContentTemplate>
<br />
<asp:Button ID="Button1" runat="server" Text="异步局部更新 UpdatePanel2" />
<br />
<%=DateTime.Now.ToString()%>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<br />
</asp:Panel>
</td>
<td valign="top" style="width: 100px; height: 13px">
<asp:Panel ID="Panel2" runat="server" Height="176px" Width="320px" GroupingText="UpdatePanel2">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
<ContentTemplate>
<br />
<asp:Button ID="Button2" runat="server" Text="异步局部更新 UpdatePanel1" />
<br />
<%=DateTime.Now.ToString()%>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<br />
</asp:Panel>
</td>
</tr>
</table>
</form>
2 如果一个上传控件fileupload放在updatepannel中,由于其不兼容updatepannel,所以必须在triggers属性中添加postbacktrigger触发器,以说明是引发全局更新