Reputation: 1379
So I've used javascript to open a popup window in asp.net with c# codebehind, and I need a buttonclick event on the popup to both close the popup and refresh the parent page. Is there a method for this?
Upvotes: 3
Views: 5561
Reputation: 6486
To change the location/refresh the parent window you can use the opener property.
This one will change the href of the parent from the pop-up.
window.opener.location.href = the_url;
The reload
method will work too,
This does a hard reload (returns forms to default values)
The optional boolean conditional argument will if true make a new request of the server, if false it will attempt to pull the page from the cache.
window.opener.location.reload(true);
If you want to preserve form data (soft reload), use the history method.
window.opener.history.go(0);
'0' causes the page to reload, a negative value represents how many steps backward you'd like to go.
Upvotes: 5