【问题标题】:How to fire update progress in child update panel?如何在子更新面板中触发更新进度?
【发布时间】:2013-01-23 05:51:39
【问题描述】:

我有嵌套的更新面板,并且都有自己的更新进度。现在,当我点击子更新面板内的按钮时,也会触发父更新进度。

如何解决这个问题?

<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>

【问题讨论】:

    标签: asp.net .net ajax updatepanel


    【解决方案1】:

    我建议您将设计修改为如下所示的 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>
    

    由于UpdatePanelParent 变为UpdateMode="Conditional",因此只有在控件中指定的Trigger 生成时才会更新,并且UpdatePanelChild 将一直更新。因此,我希望保持预期的输出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-27
      • 1970-01-01
      • 1970-01-01
      • 2011-01-28
      • 2020-10-19
      相关资源
      最近更新 更多