子UpdatePanel和父UpdateProgress问题

发布于 2024-10-04 04:10:37 字数 1348 浏览 0 评论 0原文

我有一个嵌套的子级和父级 UpdatePanel。问题是,当刷新/发布子 UpdatePanel 时,父级中的 UpdateProgress 会启动。我怎样才能防止这种情况发生?结构如下:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>

        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                    <ProgressTemplate></ProgressTemplate>
        </asp:UpdateProgress>

        <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                    <ProgressTemplate></ProgressTemplate>
        </asp:UpdateProgress>

        <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:UpdateProgress ID="UpdateProgress3" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
                                    <ProgressTemplate></ProgressTemplate>
                                </asp:UpdateProgress>
            </ContentTemplate>
                </asp:UpdatePanel>

        </ContentTemplate>
</asp:UpdatePanel>

发布UpdatePanel2时,不显示UpdateProgress3,而是显示UpdateProgress1UpdateProgress2。我应该怎么办?

I have a nested child and parent UpdatePanel. The problem is, when the child UpdatePanel is refreshed/posted, the UpdateProgress in parent fires up. How can I prevent this? The structure is like this:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>

        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                    <ProgressTemplate></ProgressTemplate>
        </asp:UpdateProgress>

        <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                    <ProgressTemplate></ProgressTemplate>
        </asp:UpdateProgress>

        <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:UpdateProgress ID="UpdateProgress3" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
                                    <ProgressTemplate></ProgressTemplate>
                                </asp:UpdateProgress>
            </ContentTemplate>
                </asp:UpdatePanel>

        </ContentTemplate>
</asp:UpdatePanel>

When UpdatePanel2 is posted, UpdateProgress3 is not displayed but UpdateProgress1 and UpdateProgress2 are. What should I do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

红尘作伴 2024-10-11 04:10:37

UpdateMode 属性UpdatePanel1 未指定,因此默认为 Always,这意味着当页面上的任何其他 UpdatePanel 执行时,UpdatePanel1 都会刷新部分回发。

尝试在所有 UpdatePanels 中指定 UpdateMode="Conditional"

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
</asp:UpdatePanel>

The UpdateMode property of UpdatePanel1 is not specified, so it defaults to Always, which means UpdatePanel1 will be refreshed when any other UpdatePanel on the page performs a partial postback.

Try specifying UpdateMode="Conditional" in all your UpdatePanels:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
</asp:UpdatePanel>
黎夕旧梦 2024-10-11 04:10:37

在这里看到: http://www.asp.net/AJAX/Documentation/实时/概述/UpdateProgressOverview.aspx

如果 UpdatePanel 控件位于另一个更新面板内,则源自子面板内部的回发会导致显示与子面板关联的任何 UpdateProgress 控件。 它还显示与父面板关联的任何 UpdateProgress 控件。如果回发源自父面板的直接子控件,则仅显示与父面板关联的 UpdateProgress 控件。这遵循如何触发回发的逻辑。

所以,我认为你必须隐藏父 UpdateProgress 客户端:

您可以使用 PageRequestManager 类的 JavaScript beginRequest 和 endRequest 事件以编程方式控制何时显示 UpdateProgress 控件。在 beginRequest 事件处理程序中,显示表示 UpdateProgress 控件的 DOM 元素。在 endRequest 事件处理程序中,隐藏该元素。

Seen here : http://www.asp.net/AJAX/Documentation/Live/overview/UpdateProgressOverview.aspx

If an UpdatePanel control is inside another update panel, a postback that originates inside the child panel causes any UpdateProgress controls associated with the child panel to be displayed. It also displays any UpdateProgress controls associated with the parent panel. If a postback originates from an immediate child control of the parent panel, only the UpdateProgress controls associated with the parent panel are displayed. This follows the logic for how postbacks are triggered.

So, I think you must hide the parent UpdateProgress clientside :

You can programmatically control when an UpdateProgress control is displayed by using the JavaScript beginRequest and endRequest events of the PageRequestManager class. In the beginRequest event handler, display the DOM element that represents the UpdateProgress control. In the endRequest event handler, hide the element.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文