模态弹出窗口扩展程序在按钮点击时未显示面板

3

我正在尝试在我的页面上使用模态弹出窗口扩展程序,这样当我点击一个按钮时,它必须显示一个面板。以下是我的代码:

    <asp:UpdatePanel runat="server" ID="updPanel">
    <ContentTemplate>
        <ajaxToolkit:ModalPopupExtender ID="mpeEmailComplete" runat="server" TargetControlID="btnTesting"
            PopupControlID="pnl" OkControlID="btnOk"
             BackgroundCssClass="modalBackground">
        </ajaxToolkit:ModalPopupExtender>



        <asp:Panel ID="pnl" runat="server" style="display:none;">
            <asp:UpdatePanel ID="udp" runat="server">
                <ContentTemplate>
                    <asp:Panel runat="server" ID="pnlEmailComplete" Visible="false">
                        <asp:Label runat="server" ID="lblTest" Text="Testing testing testing"></asp:Label>
                        <asp:Button runat="server" ID="btnOk" Text="OK" />
                    </asp:Panel>
                </ContentTemplate>
            </asp:UpdatePanel>
        </asp:Panel>


        <asp:Button runat="server" ID="btnTesting" Text="Testing"/>

    </ContentTemplate>
</asp:UpdatePanel>

但是当我点击按钮时,无法弹出面板。有人知道为什么吗?
3个回答

1
你的最内层面板的Visible属性为false。
<asp:Panel runat="server" ID="pnlEmailComplete" Visible="false">  *(change here)*

所以,当你按下TESTING按钮时,ModalPopupExtender会正确地导致外部面板显示,但它显示的是一个不可见的内部面板,因此你在屏幕上看不到任何内容。
<asp:Panel ID="pnl" runat="server" style="display:none;">  *(this is ok)*

要修复此问题,只需从外部面板(pnlEmailComplete)中删除Visible=false即可。
希望能帮到你!

0

我曾经尝试过将其放入其中,但已移除。无论有没有它,仍然无法工作... - user1202606
我遇到了一些 JavaScript 错误,但是没有任何地方设置 pnl.Visible。 - user1202606
JavaScript错误:值不能为空。参数名称:handler,同样的错误也出现在参数名称:element处。 - user1202606

0
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Button ID="Btnshow" runat="server" Text="Show" OnClick="Btnshow_Click" />
        <asp:Button ID="BtnTarget" runat="server" Text="Target" Style="display: none" />
        <asp:TextBox ID="TextBox1" runat="server">
        </asp:TextBox>
        <input type="button" value="Get" onclick="abc()" />
        <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="BtnTarget"
            PopupControlID="Panel1">
        </asp:ModalPopupExtender>
        <asp:Panel ID="Panel1" runat="server" BackColor="Black" Width="300px" Height="300px">
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Button ID="BtnHide" runat="server" Text="Hide Button" OnClick="BtnHide_Click" />
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="BtnHide" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </asp:Panel>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Btnshow" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

也许您可以解释一下您的答案,为什么它是解决方案,而不是发布一个未经记录的标记块。谢谢。 - Kev

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接