Link to home
Start Free TrialLog in
Avatar of AppDevs
AppDevs

asked on

How do I pass data back to the parent window when the child pop up is closed?

I want my pop window to pass data to the parent window when I have data updated from my child window. how do I do it?
ASKER CERTIFIED SOLUTION
Avatar of s_chilkury
s_chilkury
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Refer this link

This will work in all the browsers

http://forums.digitalpoint.com/showthread.php?t=848570

In above link we have below code

window.showModalDialog(srcFile, obj, winFeatures);

In this code, we can send obj as an array.
what do you mean by popup? is it a simple javascript popup or a ajax based modal popup?
Avatar of AppDevs
AppDevs

ASKER

I am using ASP.Net button. I would prefer to keep it that way.Since I have to implement some functionality on code behind of this button.
I opening my pop up using a method below

PARENT window code to open child window
Public Shared Sub OpenPopUp(ByVal response As HttpResponse, ByVal url As String, ByVal target As String, ByVal windowFeatures As String)
        If (String.IsNullOrEmpty(target) OrElse target.Equals("_self", StringComparison.OrdinalIgnoreCase)) AndAlso String.IsNullOrEmpty(windowFeatures) Then
            response.Redirect(url)
        Else
            Dim page As Page = CType(HttpContext.Current.Handler, Page)
            If page Is Nothing Then
                Throw New InvalidOperationException("Cannot redirect to new window outside Page context.")
            End If
            url = page.ResolveClientUrl(url)
            Dim script As String
            If (Not String.IsNullOrEmpty(windowFeatures)) Then
                script = "window.open(""{0}"", ""{1}"", ""{2}"");"
            Else
                script = "window.open(""{0}"", ""{1}"");"
            End If
            script = String.Format(script, url, target, windowFeatures)
            ScriptManager.RegisterStartupScript(page, GetType(Page), "Redirect", script, True)
        End If
    End Sub

Protected Sub lBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles lBtn.Click
            OpenPopUp("Child.aspx", "recipients", "width=800,height=700,status=0,menubar=1,toolbar=0,location=0,scrollbars=0")
      End Sub

It is working perfectly fine.
I do not have any issue with this code. I would prefer to keep it this way.

CHILD window code

Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
       /// CODE
              Page.ClientScript.RegisterStartupScript(Me.GetType(), "close", "Done();", True)          
      End Sub

ASPX code

<script language="javascript" type="text/javascript">
        function Done() {
            window.close();
        }
        </script>
Now my question is how do I refresh my Parent window when my child window is closed?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial