Refresh gridview from another window

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 ?
 
G

Guest

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();">
 
L

Laurent Bugnion [MVP]

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top