简体   繁体   English

如何关闭弹出窗口并将data参数传递给父窗口

[英]How to close popup window and pass the data parameter to parent window

On page load I am opening a popup window for Terms and Condition. 在页面加载时,我正在打开一个条款和条件弹出窗口。 Once user will click on the accept button of terms and condition popup, I need to do some DB operation on button click once the operation will complete I need to close the popup and and show the parent window and on the parent window I need to pass the DB return value 用户单击条款和条件弹出窗口的接受按钮后,我需要在按钮单击上执行一些数据库操作,一旦操作完成,我需要关闭弹出窗口并显示父窗口,并在父窗口上通过数据库返回值

$(document).ready(function () { 
        $.customDialogPopUp('Terms & Condition', '../Requisitions/TermsCondition.aspx', 95, 512);
    });

this is opening the popup. 这是打开弹出窗口。 On button click of popup window 在按钮上单击弹出窗口

    protected void btnApproved_Click(object sender, EventArgs e)
    {
        try
        {
          // DB Operation...
          // var ReqId = DB return val
          //ClientScript.RegisterClientScriptBlock(this.GetType(), "ClosePopup", "<script>CloseDialog1(); window.location.href =" + "../Requisitions/NewRequisition.aspx?ReqID="ReqId + ";</script>", true);

        }
        catch (Exception ex)
        {

        }
    }

I am struggling with line 3 of try block. 我在尝试块的第3行中苦苦挣扎。

Have done almost same things, but guess it's a little stupid method. 已经做了几乎相同的事情,但是猜测这是一个愚蠢的方法。
In parent page, add below in javascript section. 在父页面的javascript部分中添加以下内容。

function refreshByBtn() {
    document.getElementById('<%= btnApproved.ClientID %>').click();
}

In child page, add to javascript, too. 在子页面中,也添加到javascript。
guess you might modify code below. 猜猜您可能会在下面修改代码。

window.onunload = refreshParent;
function refreshParent(){
    self.opener.refreshByBtn();
}

When close child will trigger btnApproved_click() and then postback the parent page. 当关闭子级时,将触发btnApproved_click(),然后回发父级页面。

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

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