简体   繁体   English

如何从jQuery对话框回发到父页面?

[英]How to postback from jQuery Dialog to the parent page?

I have a pageA.aspx. 我有一个pageA.aspx。 In it I open a jQuery dialog with an iframe containing the pageB.asxp. 在其中,我打开一个带有包含pageB.asxp的iframe的jQuery对话框。

var dlg = $('#dialog1').html('<iframe id="ifrm"></iframe>');
dlg.dialog({
    autoOpen: false,
    resizable: false,
    draggable: false,
    modal: true
});

dlg.parent().appendTo(jQuery("form:first"));


    $('#buttonOpenDialog').click(function () {
        var url = '../PageB.aspx';
        $("#dialog1>#ifrm").attr("src", url);
        $('#dialog1').dialog('open');
        return false;
    });

Until here is all alright. 到这里一切都还好。 Now I submit the form and when postback finishes I want to close this dialog I do it like that: 现在,我提交表单,回发完成后,我想关闭此对话框,如下所示:

function closePopup() {
    parent.$("#dialog1").dialog('close');
   __doPostBack();

} }

and I want to refresh the parent page pageA.aspx without doing the ugly 而且我想刷新父页面pageA.aspx而不做难看的事情

__doPostBack()

How Can I accomplish this? 我该怎么做? thank you 谢谢

EDIT: It seems is a complex issue. 编辑:这似乎是一个复杂的问题。 Please get involved ;P 请参与; P

Add a hidden button in parent page. 在父页面中添加一个隐藏的按钮。 And when the modal closed, generate the hidden button's click event. 当模式关闭时,生成隐藏按钮的click事件。 It will refresh the parent page. 它将刷新父页面。

dlg.dialog({
    autoOpen: false,
    resizable: false,
    draggable: false,
    modal: true,
    close: function (event, ui) {
           // btnHidden is the id of the hidden button.
           document.getElementById('<%=btnHidden.ClientID%>').click();
           // To refresh gridview when user close dialog
           }
});

You can set the _target attribute of the submitted form to _parent . 您可以将提交表单的_target属性设置为_parent。 The result of the POST will then be displayed in the parent frame (pageA.aspx) POST的结果将显示在父框架(pageA.aspx)中

<form target="_parent">
</form>

Is this what you wanted? 这就是你想要的吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM