google-site-verification=ECX1M6_Vb39ty4VtQDXQce6wOjmPTxSettd3hTIZb9Q

Close Child Window and Refresh Parent Window in JavaScript

random

Close Child Window and Refresh Parent Window in JavaScript

Reload Parent Window on Popup Close

In this blog post, I will demonstrate how to refresh parent page on close of popup jquery in asp.net web application. Find the javascript code snippet below:-  
close popup window and refresh parent window,javascript refresh parent window popup,javascript parent window refresh,javascript refresh opener,reload parent window from popup,reload parent window on popup close,javascript close parent window from popup,refresh parent window from child window asp.net c#
reload parent window on popup close
Step 1: Add a new web form in your web application named parent.aspx and write the following java script function in source.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Parent Window</title>   

 <script type="text/javascript">
    function OpenChildWindow() {
//      To open a new browser window, use the window.open() method.
        window.open('ChildPage.aspx'null'height=300, width=300, status=yes, toolbar=no, menubar=no, location=center, scrollbar=no');
    }
    </script> 
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
        <p>
            Click on button to open new window</p>
        <asp:Label ID="lbltext" runat="server" />
        <asp:Button ID="btnClick" runat="server" Text="Open Child Window"OnClientClick="OpenChildWindow()" />
    </div>
    </form>
</body>
</html>

Code Behind

protected void Page_Load(object sender, EventArgs e)
    {
        // To Display Current Date:
        lbltext.Text = DateTime.Now.ToString();
    }

Step 2: Secondly add another new web form named Child.aspx and add the following code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

<title>Child Form</title>

    <script type="text/javascript">
    function closechildwindow() {
        window.opener.document.location.href = 'parent.aspx';
        window.close();
    }
    </script>

</head>

<body onunload="closechildwindow()">
    <form id="form1" runat="server">
    <div>
        <p>
            Now close the child window and notice that parent page get changed</p>
    </div>
    </form>
</body>
</html>
Close Child Window and Refresh Parent Window in JavaScript Reviewed by Ravi Kumar on 11:40 AM Rating: 5

1 comment:

All Rights Reserved by Etechpulse © 2012 - 2017

Contact Form

Name

Email *

Message *

Powered by Blogger.