[英]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.