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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what do you mean by popup? is it a simple javascript popup or a ajax based modal popup?
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(targ et) OrElse target.Equals("_self", StringComparison.OrdinalIg noreCase)) AndAlso String.IsNullOrEmpty(windo wFeatures) 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(windo wFeatures) ) Then
script = "window.open(""{0}"", ""{1}"", ""{2}"");"
Else
script = "window.open(""{0}"", ""{1}"");"
End If
script = String.Format(script, url, target, windowFeatures)
ScriptManager.RegisterStar tupScript( 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,stat us=0,menub ar=1,toolb ar=0,locat ion=0,scro llbars=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.Register StartupScr ipt(Me.Get Type(), "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?
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(targ
response.Redirect(url)
Else
Dim page As Page = CType(HttpContext.Current.
If page Is Nothing Then
Throw New InvalidOperationException(
End If
url = page.ResolveClientUrl(url)
Dim script As String
If (Not String.IsNullOrEmpty(windo
script = "window.open(""{0}"", ""{1}"", ""{2}"");"
Else
script = "window.open(""{0}"", ""{1}"");"
End If
script = String.Format(script, url, target, windowFeatures)
ScriptManager.RegisterStar
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,stat
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.Register
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This will work in all the browsers
http://forums.digitalpoint.com/showthread.php?t=848570
In above link we have below code
window.showModalDialog(src
In this code, we can send obj as an array.