最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - How to reload parent page on closing PopUp window? - Stack Overflow

programmeradmin0浏览0评论

I have a linkbutton "terms and conditions "on a master page.. when use clicks on it a popup window is displayed usingthis code

Dim myScript As String

            myScript = "<script>window.open('Terms.aspx?',null,'height=750, width=1024,status= no,resizable= no, scrollbars=yes,toolbar=no,location=no,menubar=no'); </script>"

            ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "pop", myScript, False)

I have a accept button on pop up window page on which i am closing this pop up

ClientScript.RegisterStartupScript(GetType(Page), "closePage", "window.close();", True)

The problem is i want to refresh the parent window once this pop up is closed. How can i achieve this? This did not work Refreshing Parent window after closing popup

UPDATE

<div style="padding:5px 0;">
      <asp:Button ID="btnAccept" runat="server" Text="Accept"  OnClientClick="Refresh()" style="HEIGHT: 19px;background: #C0003B;color: white; " /> &nbsp;<asp:Button ID="btnReject" runat="server" Text="Reject" OnClientClick="Refresh()" style="HEIGHT: 19px;background: #C0003B;color: white;"/>

</div>

   function Refresh() {
       return confirm('Are you sure?');
       window.onunload = refreshParent;
       function refreshParent() {
           window.opener.location.reload();
       } 
   }

I have a linkbutton "terms and conditions "on a master page.. when use clicks on it a popup window is displayed usingthis code

Dim myScript As String

            myScript = "<script>window.open('Terms.aspx?',null,'height=750, width=1024,status= no,resizable= no, scrollbars=yes,toolbar=no,location=no,menubar=no'); </script>"

            ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "pop", myScript, False)

I have a accept button on pop up window page on which i am closing this pop up

ClientScript.RegisterStartupScript(GetType(Page), "closePage", "window.close();", True)

The problem is i want to refresh the parent window once this pop up is closed. How can i achieve this? This did not work Refreshing Parent window after closing popup

UPDATE

<div style="padding:5px 0;">
      <asp:Button ID="btnAccept" runat="server" Text="Accept"  OnClientClick="Refresh()" style="HEIGHT: 19px;background: #C0003B;color: white; " /> &nbsp;<asp:Button ID="btnReject" runat="server" Text="Reject" OnClientClick="Refresh()" style="HEIGHT: 19px;background: #C0003B;color: white;"/>

</div>

   function Refresh() {
       return confirm('Are you sure?');
       window.onunload = refreshParent;
       function refreshParent() {
           window.opener.location.reload();
       } 
   }

Share Improve this question edited May 23, 2017 at 12:30 CommunityBot 11 silver badge asked Sep 11, 2013 at 8:48 SamuraiJackSamuraiJack 5,56917 gold badges103 silver badges212 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

You can access parent window using 'window.opener', so, write something like the following in the child window:

onunload="window.opener.location.reload();"

or use this

<script>
    window.onunload = refreshParent;
    function refreshParent() {
    var retVal = confirm("Are you sure ?");
           if( retVal == true ){
            window.opener.location.reload();
          else
            return false;

    }
</script>
发布评论

评论列表(0)

  1. 暂无评论