一个页面中有两个UpdatePanel

时间:2012-11-24 20:36:47

标签: c# asp.net asp.net-ajax updatepanel

我有两个更新面板,这些更新面板内部有两个modalpopup。我正在尝试从modalpopup内第一个updatepanel内的控件(按钮)更改其中一个updatepanel中的标签。单击按钮后,第一个modalpopup将关闭,第二个modalpopup将显示标签已更改但弹出窗口内的标签未显示。

当我尝试在后面的代码中调用secondUpdatePanel.Update()时,第二个模态弹出窗口甚至都没有显示出来。感谢帮助!我已经看到了从第一个弹出窗口向第二个弹出窗口分配asyncpostbacktriggers的教程,这些教程不在模态弹出窗口内。

所以,我可能会遗漏一些东西。

<asp:UpdatePanel ID="upPnlFormalAppeal" runat="server" UpdateMode="Conditional" >
        <ContentTemplate>
            <asp:HiddenField ID="hfFormalAppeal" runat="server" />
            <asp:ModalPopupExtender ID="mpopupFormalAppeal" runat="server"
                TargetControlID="hfFormalAppeal" 
                PopupControlID="pnlFormalAppealPopup" 
                CancelControlID="btnClose" 
                BackgroundCssClass="modalBackground" >
                <Animations>
                    <OnShown><Fadein Duration="0.50" /></OnShown>
                    <OnHiding><Fadeout Duration="0.75" /></OnHiding>
                </Animations>
            </asp:ModalPopupExtender>
            <!-- Details View for Formal Appeal -->
            <asp:DetailsView ID="dvFormalAppeal" runat="server" Height="50px" AutoGenerateRows="False" CssClass="dvCSS" >
                <!-- DATA HERE -->
            </asp:DetailsView>
            <div class="footer">
                <asp:LinkButton ID="btnSubmit" runat="server" Text="Submit" 
                    CausesValidation="false" OnClick="btnSubmit_Click" />
                    &nbsp;
                <asp:LinkButton ID="btnClose" runat="server" Text="Close" CausesValidation="false" />
                <asp:ConfirmButtonExtender ID="cbeSubmit" runat="server" 
                    ConfirmText="Submit Appointment Request?" TargetControlID="btnSubmit">
                </asp:ConfirmButtonExtender>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

modalpopup中的第二个UpdatePanel。

<asp:Panel ID="Panel1" runat="server" CssClass="panelConfirmation" >
    <asp:UpdatePanel ID="upPnlMessageBox" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
            <asp:HiddenField ID="hfSubmissionConfirmationBox" runat="server" />
            <asp:ModalPopupExtender ID="mpopupConfirmation" runat="server"
                TargetControlID="hfSubmissionConfirmationBox" 
                PopupControlID="Panel1" 
                CancelControlID="btnClose" 
                BackgroundCssClass="modalBackground" >
            </asp:ModalPopupExtender>
                    <div class="mpopupBody">
                        <asp:Label ID="lblConfirmationMessage" runat="server"></asp:Label>
                    </div>
                    <div class="footer">
                        <asp:Button ID="btnConfirmClose" runat="server" Text="Close" 
                            CausesValidation="false" onclick="btnConfirmClose_Click" />
                    </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="btnConfirmClose" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Panel>

代码背后。

protected void btnSubmit_Click(object sender, EventArgs e)
    {
        this.mpopupFormalAppeal.Hide();

        this.lblConfirmationMessage.Text = "Text changed!";
        //this.upPnlMessageBox.Update();
        this.mpopupConfirmation.Show();
    }

感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

对于那些具有相同场景的人......我设法通过重新排序我的布局设计来解决它。

我将modalpopup放在UpdatePanel之外,如下所示:

<asp:HiddenField ID="hfSubmissionConfirmationBox" runat="server" />
<asp:ModalPopupExtender ID="mpopupConfirmation" runat="server"
    TargetControlID="hfSubmissionConfirmationBox" 
    PopupControlID="Panel1" 
    CancelControlID="btnClose" 
    BackgroundCssClass="modalBackground" >
</asp:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" CssClass="panelConfirmation" >
    <asp:UpdatePanel ID="upPnlMessageBox" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        <ContentTemplate>
            <div class="mpopupBody">
                <asp:Label ID="lblConfirmationMessage" runat="server"></asp:Label>
            </div>
            <div class="footer">
                <asp:Button ID="btnConfirmClose" runat="server" Text="Close" 
                    CausesValidation="false" onclick="btnConfirmClose_Click" />
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="btnConfirmClose" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Panel>