ASP.NET Refreshing one window from another

I have a page with a GridView that launches a popup using Javascript. The user then selects the item that updates the data connected to the GridView and closes the popup.

How do I update the first one (like the Calling page) to update the data shown in my Gridview?

0


source to share


4 answers


Try this inside your popup:

<script>
window.opener.location.reload()
</script>

      



This should refresh the page by opening a popup

+1


source


If you just need to call the postback on the calling page, this should work:

<script>
window.parent.document.forms[0].submit();
</script>

      



By explicitly submitting the form, you avoid the warning that appears if you simply refresh the calling page.

If you need to fire the OnSelectedIndexChanged event on the GridView during a postback, things get a little weird, but you have to do it by calling window.parent.document.__doPostBack()

with the appropriate arguments.

0


source


Here's the solution:

Dim CloseScript As String = "<script language='javascript'>function closeWindow(){ window.opener.document.forms[0].submit();window.close();}closeWindow();</script>"

      

In .NET 2.0, you have to add this to the page to register above Javascript:

 'register with ClientScript 
    'The RegisterStartupScript method is also slightly different 
    'from ASP.NET 1.x 
    Dim s As Type = Me.[GetType]()
    If Not ClientScript.IsClientScriptBlockRegistered(s, "CloseScript") Then
        ClientScript.RegisterClientScriptBlock(s, "CloseScript", CloseScript)
    End If

      

0


source


Does this mean that the message "the page could not be refreshed"

window.opener.location = window.opener.location;

      

(sorry, I would just leave a comment on TonyB's post, but I don't have enough SO so I'm not allowed to ... :(

0


source







All Articles