2个更新面板总是回发

发布于 2024-10-03 04:28:33 字数 1979 浏览 0 评论 0原文

我有下面的页面,我正在绞尽脑汁为什么当我有两个更新面板时它们都会得到回发。我可以告诉,因为我有两个用户控件 - 每个面板中都有一个,当只有左侧面板应该返回并更新自身时,它们都会触发页面加载事件...否则,如果实际上是整个页面,那么更新面板的意义何在正在回帖!!!

我在这里缺少什么?

<asp:Content ID="StyleContent" ContentPlaceHolderID="Style" runat="server">
<link href="../Styles/ReportWizard.css" rel="stylesheet" type="text/css" />


<div class="clearFix"></div>

<div class="wizardContainer">
<asp:UpdatePanel runat="server" ID="pnlWizard">
    <ContentTemplate>
        <table>
            <tr>
                <td>
                    <asp:Panel runat="server" ID="pnlContainer"  CssClass="leftWindow" />
                </td>
            </tr>
            <tr><td>
                <input type="hidden" name="rwReport" id="rwReport" />
                <input type="hidden" name="rwProject" id="rwProject" />
                <input type="hidden" name="rwStakeholder" id="rwStakeholder" />
                <input type="hidden" name="rwStakeholderNames" id="rwStakeholderNames" />
                <input type="hidden" name="rwMilestone" id="rwMilestone"/></td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Button runat="server" ID="cbPrev" Text="Previous" CssClass="rwButton" OnClick="cbPrev_Click" OnClientClick="return updateBC('bwd');" />
                    <asp:Button runat="server" ID="cbNext" Text="Next" cssClass="rwButton" OnClick="cbNext_Click" />
                </td>
            </tr>
        </table>
    </ContentTemplate>
</asp:UpdatePanel>

i have the below page and i am racking my brain as to why when i have two update panels do they both get post backs. i can tell cause i have two user controls- one in each panel and they both fire page load events when only the left panel should be posing back and updating itself... or else whats the point of update panels if in reality the entire page is posting back!!!

what am i missing here?

<asp:Content ID="StyleContent" ContentPlaceHolderID="Style" runat="server">
<link href="../Styles/ReportWizard.css" rel="stylesheet" type="text/css" />

<div class="clearFix"></div>

<div class="wizardContainer">
<asp:UpdatePanel runat="server" ID="pnlWizard">
    <ContentTemplate>
        <table>
            <tr>
                <td>
                    <asp:Panel runat="server" ID="pnlContainer"  CssClass="leftWindow" />
                </td>
            </tr>
            <tr><td>
                <input type="hidden" name="rwReport" id="rwReport" />
                <input type="hidden" name="rwProject" id="rwProject" />
                <input type="hidden" name="rwStakeholder" id="rwStakeholder" />
                <input type="hidden" name="rwStakeholderNames" id="rwStakeholderNames" />
                <input type="hidden" name="rwMilestone" id="rwMilestone"/></td>
            </tr>
            <tr>
                <td align="right">
                    <asp:Button runat="server" ID="cbPrev" Text="Previous" CssClass="rwButton" OnClick="cbPrev_Click" OnClientClick="return updateBC('bwd');" />
                    <asp:Button runat="server" ID="cbNext" Text="Next" cssClass="rwButton" OnClick="cbNext_Click" />
                </td>
            </tr>
        </table>
    </ContentTemplate>
</asp:UpdatePanel>

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

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

发布评论

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

评论(2

高跟鞋的旋律 2024-10-10 04:28:35

首先,您没有指定 UpdateMode UpdatePanels 的属性,以便它们默认为始终。这意味着当其中一个面板执行部分回发时,两个面板都会刷新。您需要指定这些属性并将其设置为有条件

也就是说,您的两个用户控件在每次回发(甚至是部分回发)时都会经历其 Load 阶段,这是完全正常的。整个页面生命周期实际上发生在部分回发期间,就像在完整回发期间一样,但在部分回发期间,仅将结果页面标记的一部分发送到浏览器。

First, you don't specify the UpdateMode properties of your UpdatePanels, so they default to Always. That means both panels will be refreshed when one of them performs a partial postback. You need to specify these properties and set them to Conditional.

That said, it's perfectly normal that both your user controls go through their Load phase on each postback, even partial ones. The whole page lifecycle actually takes place during a partial postback, just like it does during a full postback, but during a partial postback only part of the resulting page markup is sent to the browser.

梦行七里 2024-10-10 04:28:35

您在更新面板中缺少一个属性:

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

这将使更新面板仅在其子控件之一或其 之一导致回发时更新。

You are missing an attribute in the Update Panel:

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

This will make the Update Panel only update if one of its child controls OR one of its <Triggers> causes a postback.

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