2013-01-23 59 views
0

我有嵌套更新面板,都有自己的更新进度。现在,当我点击子更新面板中的按钮时,父级的更新进度也会被触发。如何触发子更新面板中的更新进度?

如何解决这个问题?

<asp:UpdatePanel ID="UpdatePanelParent" runat="server"> 
     <ContentTemplate> 
      ... 
      ... some controls 
      ... 
      <asp:UpdatePanel ID="UpdatePanelChild" runat="server" > 
       <ContentTemplate> 
        ... 
        ... some controls 
       </ContentTemplate> 
      </asp:UpdatePanel> 

      <asp:UpdateProgress ID="UpdateProgressChild" runat="server" AssociatedUpdatePanelID="UpdatePanelChild" DisplayAfter="0"> 
       <ProgressTemplate>  
        Updating child... 
       </ProgressTemplate> 
       </asp:UpdateProgress> 


     </ContentTemplate> 
</asp:UpdatePanel>  
<asp:UpdateProgress ID="UpdateProgressParent" runat="server" AssociatedUpdatePanelID="UpdatePanelParent" DisplayAfter="0"> 
    <ProgressTemplate>  
     Updating parent... 
    </ProgressTemplate> 
</asp:UpdateProgress> 

回答

0

我建议你修改你的设计为2个独立的更新面板,如下所示,而不是嵌套它们。

<asp:UpdatePanel ID="UpdatePanelParent" runat="server" UpdateMode="Conditional"> 
      <ContentTemplate> 
       <asp:Label ID="lblParent" runat="server" Text="Label"></asp:Label> 
       <asp:Button ID="btnParent" runat="server" Text="Button" OnClick="btnParent_Click" /> 
      </ContentTemplate> 
      <Triggers> 
       <asp:AsyncPostBackTrigger ControlID="btnParent" EventName="Click" /> 
      </Triggers> 
     </asp:UpdatePanel> 
     <asp:UpdatePanel ID="UpdatePanelChild" runat="server"> 
      <ContentTemplate> 
       <asp:Label ID="lblChild" runat="server" Text="Label"></asp:Label> 
       <asp:Button ID="btnChild" runat="server" Text="Button" OnClick="btnChild_Click" /> 
      </ContentTemplate> 
     </asp:UpdatePanel> 
     <asp:UpdateProgress ID="UpdateProgressChild" runat="server" AssociatedUpdatePanelID="UpdatePanelChild" 
      DisplayAfter="0"> 
      <ProgressTemplate> 
       Updating child... 
      </ProgressTemplate> 
     </asp:UpdateProgress> 
     <asp:UpdateProgress ID="UpdateProgressParent" runat="server" AssociatedUpdatePanelID="UpdatePanelParent" 
      DisplayAfter="0"> 
      <ProgressTemplate> 
       Updating parent... 
      </ProgressTemplate> 
     </asp:UpdateProgress> 

由于UpdatePanelParentUpdateMode="Conditional",只有当从控制指定Trigger由它得到更新和UpdatePanelChild将得到更新,所有的时间。因此保持预期的产出,我希望。