Refresh gridview from another window

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My form includes a gridview with existing clients.

I use the code below for opening a new window for adding a new client or
updating an existing one.

If (Not Page.ClientScript.IsStartupScriptRegistered(Me.GetType(),
"Client")) Then
Page.ClientScript.RegisterStartupScript(Me.GetType(), "Client",
"window.open(Client.aspx',
'','Height=700px,Width=700px,menubar=No,toolbar=no,scrollbars=yes'); ", True)
End If

On Client form in close button I have the code below:

If (Not Page.ClientScript.IsStartupScriptRegistered(Me.GetType(),
"Window_Close")) Then
Page.ClientScript.RegisterStartupScript(Me.GetType(),
"Window_Close", "window.close();", True)
End If

How can I refresh the first form with all clients for showing the new client ?
 
Thanks a lot Manish for your reply.

The window.opener.document.forms(0).submit(); works perfect.

Can I add the code when my page has a master page and <body> is not
available in asp source ?

<body onunload="opener.location.reload();">
 
Hi,
Thanks a lot Manish for your reply.

The window.opener.document.forms(0).submit(); works perfect.

Can I add the code when my page has a master page and <body> is not
available in asp source ?

<body onunload="opener.location.reload();">

You can add events dynamically using JavaScript:

function myFunction()
{
if ( window.opener )
{
window.opener.location.reload();
}
}

window.onunload = myFunction;

(Note: No parenthesis! You assign the function itself to the event
handler, not the functions's result!!

Laurent
 
Thanks Laurent,

I used the code below, but I receive an error that ; is missing.

Protected Sub Page_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Init

If Not (Page.ClientScript.IsClientScriptBlockRegistered(Me.GetType(),
"Onunload")) Then
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "Onunload",
"function myFunction(){If (window.opener) Then
{window.opener.location.reload();}} window.onunload = myFunction;", True)
End If
 
Back
Top