2010-09-18 85 views
1

我有兩個嵌套的UpdatePanle和父窗格中的按鈕和編輯器以及子面板中的GridView。嵌套更新面板問題

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> 
    <ContentTemplate> 
     <asp:Button ID="btn_UsersList" runat="server" 
      OnClick="btn_UsersList_Click" Text="users" /> 
     <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> 
      <ContentTemplate> 
       <asp:GridView ID="GridView_UsersList" runat="server"> 
       </asp:GridView> 
      </ContentTemplate> 
      <Triggers> 
       <asp:AsyncPostBackTrigger ControlID="btn_UsersList" 
        EventName="Click" /> 
      </Triggers> 
     </asp:UpdatePanel> 
     <fckeditorv2:fckeditor id="FCKeditor_Message" runat="server" 
      basepath="~/fckeditor/"></fckeditorv2:fckeditor> 
    </ContentTemplate> 
</asp:UpdatePanel> 

我想單擊按鈕時更新子面板,但不更新父UpdatePanel.How我可以這樣做嗎?我的代碼有什麼問題? 預先感謝您

回答

1

ChildrenAsTriggers="false",然後在每個單獨的UpdatePanel 使用<triggers>標籤(我通常把它放在右下方我 ContentTemplate)手動指定控制更新面板上 更新。我幾乎總是使用這個,所以我知道是什麼導致我的 回發,我沒有我不知道發生的事情。

例子:

<UpdatePanel id="Parent" ChildrenAsTriggers="false" UpdateMode="conditional"> 
    <ContentTemplate> 
     <UpdatePanel id="Child" ChildrenAsTriggers="false" UpdateMode="conditional"> 
      <ContentTemplate> 
       <!-- Content Here --> 
      </ContentTemplate> 
      <Triggers> 
       <!-- Updates only the child panel --> 
       <asp:AsynchronousPostBackTrigger 
        ControlID="btnChangeChildPanel" EventName="Click" /> 
      </Triggers> 
     </UpdatePanel> 
     <asp:Button id="btnChangeChildPanel" runat="server" 
      OnClick="btnChangeChildPanel_OnClick" /> 
    </ContentTemplate> 
    <Triggers> 
     <!-- Add parent triggers here --> 
    </Triggers> 
</UpdatePanel> 
+0

不要忘了你可以調用面板中的Refresh()方法... – jcolebrand 2010-09-19 11:18:48

0

@sohren

你可能需要在某些時候解鎖界面。你可以使用pageLoad()函數來達到這個目的。如果您的AJAX請求在阻止UI後成功運行,則在收到響應並更新頁面時將調用pageLoad()函數。這是您可以取消阻止用戶界面的地方。

+0

???解除屏蔽用戶界面?你在說什麼?問題在於他使用的是嵌套更新面板,而不是指定哪一個面板是父級與子級。因此,根據上面的答案,您需要專門將ChildrenAsTrigger設置爲false。 – Fandango68 2016-07-06 01:13:16