Reputation: 689
In a child popup window I have the following button.
<asp:Button Style="width: 100%;" ID="Button2" runat="server" OnClientClick="RefreshParent()"
OnClick="Button1_Click" Text="Select Study" />
The OnClick function allows the user to select a study which changes the entire site's content, this part works fine, thus isn't listed.
The OnClientClick function should refresh the parent page, but doesn't cause the client data to update unless I manually refresh the page (F5). Here is the RefreshParent code.
<script type="text/javascript">
function RefreshParent() {
window.opener.document.reload()
window.close();
}
</script>
In the function I have also tried:
window.opener.document.reload(true)
and
window.opener.document.href("home.aspx")
Nothing worked. Is there a method that will cause a server postback from a child window with either the code behind or javascript? Thanks.
Upvotes: 1
Views: 6188
Reputation: 21905
I think what is happening is that your reload of the parent page is done before your popup window OnClick method has executed. In order to have your reload script execute after the post back is finished, I suggest you wrap your script in a placeholder which is displayed after postback:
<asp:placeholder id="refresh_script" visible="false" runat="server">
<script type="text/javascript">
window.opener.location.reload();
window.close();
</script>
</asp:placeholder>
In your OnClick handler:
refresh_script.Visible = true;
Remove the OnClientClick handler from your button.
Upvotes: 0
Reputation: 15413
have you tried :
<script type="text/javascript">
function RefreshParent() {
window.opener.location.reload();
window.close();
}
</script>
You might also want to return false in the OnClientClick (not really a matter as you are closing window)
Upvotes: 1