Refresh parent page from child popup RRS feed

  • Question

  • User-810045358 posted

    I have a button on the parent page . Upon clicking the button I am redirecting to a new page using HTTP post in a POPUP using window open and I am using C# for this.

    sb.Append(string.Format("</head><body onload=\"document.form1.target = 'myActionWin';window.open('','myActionWin','width=800,height=800,toolbar=0');;document.{0}.submit();window.opener.location.reload();\">", FormName));

    I am getting an exception saying the opener location is undefined.

    Can anyone please help me out this and let me know how I can refresh the parent page.

    Wednesday, November 30, 2016 4:17 PM

All replies

  • User-707554951 posted

    Hi durga123,

    Based on your need, I make an example, I suggest you could refer to it.


    <script type="text/javascript">
            function SelectName() {
                var child = window.open('http://localhost:60925/Test/ChildPage.aspx', "Popup", "width=300,height=100");
       <input id="Text1" type="text" />
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/>
     protected void Button1_Click(object sender, EventArgs e)
                Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "SelectName();", true);


     <script type="text/javascript">
            function SetName() {
                if (window.opener != null && !window.opener.closed) {
                    var txt = window.opener.document.getElementById("Text1");
                    txt.value = document.getElementById("ddlNames").value;
     <asp:TextBox ID="ddlNames" runat="server"></asp:TextBox>
    <button onclick="SetName()">Copy</button>

    Output screenshot as below:


    If the example above didn’t solve your problem, would you please provide us with more code about how you open your popup window? So that we could find the reason for your problem.

    Best regards


    Thursday, December 1, 2016 7:14 AM