打开 aspx 页面作为模式弹出窗口

发布于 2024-11-28 03:56:36 字数 223 浏览 0 评论 0原文

我有一个带有编辑选项的网格,在编辑按钮上单击我需要重定向到编辑页面。 要求是将此编辑页面作为弹出窗口,背景(上一页)呈灰色。

我尝试了模式弹出窗口,但控件位于单独的页面上。

我尝试使用面板和 Iframe 进行模式弹出:这有效。但是出现了另一个问题。我需要在“保存”或“取消”按钮上关闭页面,然后单击。这些控件将位于编辑页面上,而不是在上一个页面上页。任何帮助表示赞赏。

谢谢 拉贾特

I have a grid with edit option ,and on edit button click i need to redirect to an edit page .
the requirement is to get this edit page as a popup with background (prev page) greyed out.

i tried modal popup, but the controls are on a separate page .

i tried modal popup with panel and a Iframe : this works..but thean another problem arises.i need to close the page on 'SAVE' or 'Cancel' butotn click .these controls would be on the edit page and not on the prev page .any help is appreciated .

Thanks
Rajat

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

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

发布评论

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

评论(5

榕城若虚 2024-12-05 03:56:36

我强烈建议使用用户控件,因为它会更方便您管理,并且没有必要为其创建整个页面,因为 bcz 模式弹出窗口使用 ajax 请求,如果您尝试在其中加载页面,那么您就可以了做表单发布...这不符合使用ajax请求或表单发回...

加上我正在寻找你的问题的答案,我发现了这篇文章,它说:

您可以使用模态弹出扩展器打开页面的某些部分:
弹出窗口。但我们没有任何属性来打开其他 html 或 aspx
弹出窗口中的页面。

http:// /wiki.asp.net/page.aspx/1378/open- Different-page-using-ajax-modal-popup-extender-control/

还发现人们问与您相同的问题以及他们得到的答复在这里

使用 Iframe 或用户控件

有没有办法使用 ModalPopup Extender 打开另一个页面?

我建议修改您的设计,因为它不会造成任何损害,相反,它会更有帮助......

希望这有所帮助......

i'll strongly suggest to use user control as it'll be more handy for you to manage and there is no point creating a whole page for it bcz modal popup uses ajax request and if you try to load the page in it then you have to do form post ... which doesn't go along either use ajax request or form post back ...

plus i was looking for the answer of ur question and i came across this article where it says:

You May use Modal Popup Extender to open some part of the page as
Popup. But there we don't have any property to open other html or aspx
page in Popup window.

http://wiki.asp.net/page.aspx/1378/open-different-page-using-ajax-modal-popup-extender-control/

and also found people asking same question as you did and the response they got is here

use Iframe or user control

Is there a way to open another page using ModalPopup Extender?

and i'll suggest to modify your design as it doesn't do any harm, instead it'll be much more helpful ...

hope this help ...

旧人哭 2024-12-05 03:56:36

我已经多次使用 AJAX 控件工具包中的模态弹出控件,并取得了很好的成功:
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/ModalPopup /ModalPopup.aspx

I've used the Modal Popup Control from the AJAX Control Toolkit several times with good success:
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/ModalPopup/ModalPopup.aspx

够运 2024-12-05 03:56:36

如果您使用 bootstrap Modal,那么您可以将 iframe 添加到模态主体中,并在其中加载页面的 url。

<div class="modal fade" id="modalC" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">Cantidad reservas mensuales</h4>
            </div>
            <div class="modal-body" id="content">
                <iframe src="your new page url">
            </div>
        </div>
    </div>
</div>

If you are using bootstrap Modal then you can add an iframe into the modal body and load the url of your page inside it.

<div class="modal fade" id="modalC" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">Cantidad reservas mensuales</h4>
            </div>
            <div class="modal-body" id="content">
                <iframe src="your new page url">
            </div>
        </div>
    </div>
</div>
-黛色若梦 2024-12-05 03:56:36

只是一个想法,但是使用 jquery“contents()”函数怎么样?

您可以设置一个间隔来从父页面查找 iframe 内的元素。
(您使用的是 .net,因此您可以使其在 iframe 页面回发时显示)。

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="admin_test" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>    
    <script>
        $(function () {

            var watchForClose = setInterval(function () {
                if ($('#testIframe').contents().find('#closeModal').length > 0) {
                    clearInterval(watchForClose);
                    /* call function to close modal here..*/
                    alert('Close modal');
                };
            }, 100);

        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <iframe id="testIframe" src="Default.aspx" width="300" height="300"></iframe>
    </div>
    </form>
</body>
</html>

上面的内容是在 iframe 页面中查找 id 为“closeModal”的元素。当该元素出现时,您可以调用模式的关闭函数(只需将警报替换为调用)。

Just an idea but what about using the jquery "contents()" function?

You could set an interval to look for an element within the iframe from the parent page.
(You're using .net so you could make it appear upon postback on the iframe's page).

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="admin_test" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>    
    <script>
        $(function () {

            var watchForClose = setInterval(function () {
                if ($('#testIframe').contents().find('#closeModal').length > 0) {
                    clearInterval(watchForClose);
                    /* call function to close modal here..*/
                    alert('Close modal');
                };
            }, 100);

        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <iframe id="testIframe" src="Default.aspx" width="300" height="300"></iframe>
    </div>
    </form>
</body>
</html>

The above is looking for an element within the iframe-page with an id of "closeModal". When that element appears you can make a call to the modal's close function, (just replace the alert with the call).

谁把谁当真 2024-12-05 03:56:36

我们可以使用 IFrame 打开一个 aspx 作为弹出窗口,如下所示,

首先使用一个按钮并提供 onclick 事件,如下所示

   <input id="btnSymbol" type="button" value="..." onclick="OpenMyPopUp()" runat="server"/> 

下一步在页面中提供一个带有 id 的“Div”标签,

   <div id="MyDialog">
        </div>

如下然后找到下面的两个方法,它们采用当前 URL 并打开一个使用 IFRAME 弹出的 aspx 页面

    function OpenMyPopUp(){openPopup('OpenPage.aspx', 530, 800, 'Page Title');}

发送的四个参数如下 URL、高度、宽度、标题

   function openPopup(url, h, w, t) {
if (url != null && h != null && w != null && t != null) {

    urlBase = location.href.substring(0, location.href.lastIndexOf("/") + 1);
    url = urlBase + url;
    $('#MyDialog').html('<iframe border=0 width="100%" height ="100%" src="' + url + '"> </iframe>');
    $("#MyDialog").dialog({
        title: t,
        modal: true,
        autoOpen: true,
        height: h,
        width: w,
        resizable: false,
        position: ['right-10', 'top+30'],
        closeOnEscape: false,
        dialogClass: "alert"
    });
}}

We can open an aspx as popup using IFrame as follows,

First take a button and provide onclick event as follows

   <input id="btnSymbol" type="button" value="..." onclick="OpenMyPopUp()" runat="server"/> 

Next In the page provide a "Div" tag with id as follows

   <div id="MyDialog">
        </div>

Then find below the two methods which take the present URL and opens a aspx page in a popup using IFRAME

    function OpenMyPopUp(){openPopup('OpenPage.aspx', 530, 800, 'Page Title');}

The Four parameters are sent as follows URL,height,width,title

   function openPopup(url, h, w, t) {
if (url != null && h != null && w != null && t != null) {

    urlBase = location.href.substring(0, location.href.lastIndexOf("/") + 1);
    url = urlBase + url;
    $('#MyDialog').html('<iframe border=0 width="100%" height ="100%" src="' + url + '"> </iframe>');
    $("#MyDialog").dialog({
        title: t,
        modal: true,
        autoOpen: true,
        height: h,
        width: w,
        resizable: false,
        position: ['right-10', 'top+30'],
        closeOnEscape: false,
        dialogClass: "alert"
    });
}}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文