ASP.Net:在 ModalPopupExtander 中从 iframe 控制 MainPage

发布于 2024-10-14 21:28:38 字数 1855 浏览 4 评论 0原文

我有一个页面“Default.aspx”。 在此页面中是一个带有 iFrame 的 ModalPopupControl:

 <div style="float: right; margin-right: 10px; margin-top: 8px;">
                        <asp:Button ID="btnSearchGo" runat="server" Text="Jetzt suchen" OnClick="btnSearchGo_Click" />
                    </div>
                    <asp:ModalPopupExtender BackgroundCssClass="ModalPopupBG" OkControlID="linkClosestartSeach"
                        PopupDragHandleControlID="PopupHeader" ID="mpeMiniSearch" runat="server" TargetControlID="linkFooterImpressum"
                        PopupControlID="panMiniSearch">
                    </asp:ModalPopupExtender>
                    <asp:Panel Style="display: none" ID="panMiniSearch" runat="server">
                        <div class="HellowWorldPopup">
                            <div class="PopupHeader" id="Div10">
                                Suche</div>
                            <div class="PopupBody">
                                <iframe id="iFrameMiniSearch" runat="server" src="MiniSearch.aspx" class="iFramePopUp">
                                </iframe>
                            </div>
                            <div class="popupFooter">
                                <asp:LinkButton Text="Schließen" class="linkPupopClose" runat="server" ID="linkClosestartSeach"></asp:LinkButton>
                            </div>
                        </div>
                    </asp:Panel>



 protected void btnSearchGo_Click(object sender, EventArgs e)
    {
        iFrameMiniSearch.Attributes["src"] = "MiniSearch.aspx";
   //Do More
        mpeMiniSearch.Show();
    }

现在,我在 iFrame 中有一个 LinkBut​​ton,它应该关闭 MPE 并将页面 Default.aspx 重定向到 Register.aspx。

知道怎么做吗?

I have a page "Default.aspx".
In this page is a ModalPopupControl with an iFrame:

 <div style="float: right; margin-right: 10px; margin-top: 8px;">
                        <asp:Button ID="btnSearchGo" runat="server" Text="Jetzt suchen" OnClick="btnSearchGo_Click" />
                    </div>
                    <asp:ModalPopupExtender BackgroundCssClass="ModalPopupBG" OkControlID="linkClosestartSeach"
                        PopupDragHandleControlID="PopupHeader" ID="mpeMiniSearch" runat="server" TargetControlID="linkFooterImpressum"
                        PopupControlID="panMiniSearch">
                    </asp:ModalPopupExtender>
                    <asp:Panel Style="display: none" ID="panMiniSearch" runat="server">
                        <div class="HellowWorldPopup">
                            <div class="PopupHeader" id="Div10">
                                Suche</div>
                            <div class="PopupBody">
                                <iframe id="iFrameMiniSearch" runat="server" src="MiniSearch.aspx" class="iFramePopUp">
                                </iframe>
                            </div>
                            <div class="popupFooter">
                                <asp:LinkButton Text="Schließen" class="linkPupopClose" runat="server" ID="linkClosestartSeach"></asp:LinkButton>
                            </div>
                        </div>
                    </asp:Panel>



 protected void btnSearchGo_Click(object sender, EventArgs e)
    {
        iFrameMiniSearch.Attributes["src"] = "MiniSearch.aspx";
   //Do More
        mpeMiniSearch.Show();
    }

Now I have a LinkButton in the iFrame that should close the MPE and redirect the Page Default.aspx to Register.aspx.

Any Idea how to do?

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

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

发布评论

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

评论(1

陈独秀 2024-10-21 21:28:38

首先,您需要为 ModalPopupExtender 指定一个 BehaviorID,以便您可以从客户端访问它。该属性默认为扩展程序的 ClientID,该属性会根据容器链的不同而有所不同,因此最好明确指定它:

<asp:ModalPopupExtender ID="mpeMiniSearch" runat="server"
    BehaviorID="mpeMiniSearch" BackgroundCssClass="ModalPopupBG"
    OkControlID="linkClosestartSeach" PopupDragHandleControlID="PopupHeader"
    TargetControlID="linkFooterImpressum" PopupControlID="panMiniSearch">
</asp:ModalPopupExtender>

然后,您可以调用 $find() 来自 LinkBut​​tonClientClick 事件:

function yourLinkButton_clientClick()
{
    var modalPopup = window.parent.$find("mpeMiniSearch");
    if (modalPopup != null) {
        modalPopup.hide();
        window.parent.location.href = "Register.aspx";
    }
}

First, you'll need to specify a BehaviorID for your ModalPopupExtender, so you can access it from the client side. That property defaults to the ClientID of the extender, which will vary depending on the container chain, so it's best to specify it explicitly:

<asp:ModalPopupExtender ID="mpeMiniSearch" runat="server"
    BehaviorID="mpeMiniSearch" BackgroundCssClass="ModalPopupBG"
    OkControlID="linkClosestartSeach" PopupDragHandleControlID="PopupHeader"
    TargetControlID="linkFooterImpressum" PopupControlID="panMiniSearch">
</asp:ModalPopupExtender>

Then, you can call $find() from your LinkButton's ClientClick event:

function yourLinkButton_clientClick()
{
    var modalPopup = window.parent.$find("mpeMiniSearch");
    if (modalPopup != null) {
        modalPopup.hide();
        window.parent.location.href = "Register.aspx";
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文