Solved

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

Posted on 2011-02-11
5
314 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now