开发者

2 update panels always posting back

开发者 https://www.devze.com 2023-01-25 04:25 出处:网络
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 pag

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" />
                <开发者_如何学Python;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>


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号