第一个面板中的第一个modalpopup在第二个面板中打开第二个modalpopup之前不会打开

时间:2013-01-05 05:36:51

标签: c# asp.net ajax

我有两个面板存在一个updatepanel。每个面板都有两个按钮来打开弹出窗口。我有两个modalpopup&它的目标面板位于两个面板的下方。一切正常,但我遇到问题,如果我在第一个面板中单击按钮然后modalpopup无法打开,但是当我在第一个面板中单击按钮后单击第二个面板中的按钮然后弹出打开&安培;反之亦然。 我使用了以下代码:

<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
    <asp:Panel ID="pnl1" runat="server">
        <asp:Button ID="btn1" runat="server" class="add-btn-1" Text="Add" />
    </asp:Panel>
    <asp:Panel ID="pnl2" runat="server">
        <asp:Button ID="btn2" runat="server" class="add-btn-1" Text="Add" />
    </asp:Panel>
    <cc1:ModalPopupExtender ID="ModalPopup1" PopupControlID="pnlpopup1" TargetControlID="btn1"
        BackgroundCssClass="modalBackground" runat="server" />
    <asp:Panel runat="server" ID="pnlpopup1">
    <%--code here--%>
    </asp:Panel>
    <cc1:ModalPopupExtender ID="ModalPopup2" PopupControlID="pnlpopup2" TargetControlID="btn2"
        BackgroundCssClass="modalBackground" runat="server" />
    <asp:Panel runat="server" ID="pnlpopup2">
    <%--code here--%>
    </asp:Panel>
</ContentTemplate>

解决这个问题的解决方案是什么?

谢谢。

2 个答案:

答案 0 :(得分:0)

我执行了你的代码并发现没有问题。它的工作原理。发布你在&lt;% - 代码 - %&gt; 里面给出的代码。我也建议你将 OkControlID 添加到ModalPopupExtender。

答案 1 :(得分:0)

<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Panel ID="pnl1" runat="server">
            <asp:Button ID="btn1" runat="server" class="add-btn-1" Text="Add" />
        </asp:Panel>
        <asp:Panel ID="pnl2" runat="server">
            <asp:Button ID="btn2" runat="server" class="add-btn-1" Text="Add" />
        </asp:Panel>
        <Ajax:ModalPopupExtender ID="ModalPopup1" PopupControlID="pnlpopup1" TargetControlID="btn1"
            BackgroundCssClass="modalBackground" runat="server" />
        <asp:Panel runat="server" ID="pnlpopup1" Style="width:400px;height:100px; background: gray;">
            <table width="100%">
                <tr>
                    <td align="left">
                        <asp:Label ID="lblheadinglunchout" Font-Underline="true" Text="First Popup"
                            runat="server" CssClass="labelPopup" Style="text-decoration: none"></asp:Label>
                    </td>
                    <td align="right">
                        <asp:ImageButton  ID="imgbtnCancelPopUp" ImageUrl="Images/popupclose_button.png"
                            runat="server" Style="vertical-align: top;" CssClass="button" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
        <Ajax:ModalPopupExtender ID="ModalPopup2" PopupControlID="pnlpopup2" TargetControlID="btn2"
            BackgroundCssClass="modalBackground" runat="server" />
        <asp:Panel runat="server" ID="pnlpopup2" Style="width:400px;height:100px; background: gray;">
           <table width="100%">
                <tr>
                    <td align="left">
                        <asp:Label ID="Label1" Font-Underline="true" Text="Secound Popup"
                            runat="server" CssClass="labelPopup" Style="text-decoration: none"></asp:Label>
                    </td>
                    <td align="right">
                        <asp:ImageButton  ID="ImageButton1" ImageUrl="Images/popupclose_button.png"
                            runat="server" Style="vertical-align: top;" CssClass="button" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </ContentTemplate>
</asp:UpdatePanel>