Solved

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

Posted on 2011-02-11
5
324 Views
Last Modified: 2012-05-11
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?
0
Comment
Question by:AppDevs
5 Comments
 
LVL 9

Accepted Solution

by:
s_chilkury earned 250 total points
ID: 34876909
0
 
LVL 12

Expert Comment

by:jagssidurala
ID: 34876938
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.
0
 
LVL 7

Expert Comment

by:meispisces
ID: 34878075
what do you mean by popup? is it a simple javascript popup or a ajax based modal popup?
0
 

Author Comment

by:AppDevs
ID: 34888487
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?
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 34895377
Try the following


http://wiki.asp.net/page.aspx/282/passing-value-from-popup-window-to-parent-form39s-textbox/


The main thing is this line
window.opener.document.getElementById("ctl00_ContentPlaceHolder1_TextBox2").value = val;

it accesses the "Opener" of current window which is the parent window and sets value of a textbox in parent window.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question