[英]Problem with “Update panel” control
我正在使用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>
我认为您必须以这种方式使用更新面板:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
</asp:UpdatePanel>
如果UpdateMode无法解决您的问题,请尝试使用此方法:
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" ChildrenAsTriggers="false" runat="server">
</asp:UpdatePanel>
因为关于ASP.NET Ajax UpdatePanel的很酷的事情是,当内部引发通常会产生回发事件的事件时,异步地更新其内容,所以人们会认为这是其默认行为。
但这不是:UpdatePanel的UpdateMode属性具有2个可能的值:
且默认值为始终。
设置为“始终”时,UpdatePanel会在页面上任何位置引发的每次回发中更新,因此会从面板内部,其他面板内部或页面上的控件进行更新。
当设置为“条件”时,UpdatePanel仅在由面板内的控件或指定的触发器发起的回发时进行更新。
因此,如果您有多个更新面板,并且不想每次都更新所有要更新的面板,则必须将UpdateMode设置为Conditional
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.