我正在使用ASP.NET,其中我使用Ajaxcontroltoolkit和“更新面板”控件来更新页面部分。
我第一次运行程序时工作正常,但从第二次“更新面板”控件不起作用。我可以提供更多关于它的细节,任何想法是什么问题?
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table border="1" id="tbRegistration" style="font-family: Calibri" width="800px">
<tr>
<td style="width: 33%" align="center">
<asp:RadioButton ID="rbIndividual" runat="server" OnCheckedChanged="RadioButton_CheckedChanged"
Text="Individual" GroupName="Profile" AutoPostBack="true" />
</td>
<td style="width: 33%" align="center">
<asp:RadioButton ID="rbAgent" runat="server" OnCheckedChanged="RadioButton_CheckedChanged"
Text="Agent" GroupName="Profile" AutoPostBack="true" />
</td>
<td style="width: 33%" align="center">
<asp:RadioButton ID="rbBuilder" runat="server" OnCheckedChanged="RadioButton_CheckedChanged"
Text="Builder" GroupName="Profile" AutoPostBack="true" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
答案 0 :(得分:3)
我认为您必须以这种方式使用更新面板:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
</asp:UpdatePanel>
答案 1 :(得分:3)
如果UpdateMode无法解决您的问题,请尝试使用:
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" ChildrenAsTriggers="false" runat="server">
</asp:UpdatePanel>
由于ASP.NET Ajax UpdatePanel很酷,因为当内部引发通常会生成回发的事件时,其内容会异步更新,人们会认为这是默认行为。
但事实并非如此:UpdatePanel的UpdateMode属性有两个可能的值:
,默认值为Always。
当设置为Always时,UpdatePanel会在页面中任何位置提升的每个回发时更新,因此可以从面板内部的控件,其他面板内部或页面上的控件进行更新。
当设置为Conditional时,UpdatePanel将仅在由面板内的控件或指定的触发器发起的回发时更新。
因此,如果您有多个更新面板并且您不希望每次更新所有更新面板,则必须将UpdateMode设置为条件