Here I will explain how to refresh parent window when child window is closed using JavaScript in asp.net.
In previous articles I explained Open Child window from parent window and display child window values in parent window, Set Default homepage in IE and Mozilla, Redirect to another page after some time delay, jQuery Remove first/last character from string, jQuery Drag and Drop Example, and many articles relating to JavaScript and JQuery. Now I will explain how to refresh parent window when child window is closed using JavaScript in asp.net.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<script type="text/javascript">
function OpenChildWindow() {
window.open('ChildPage.aspx',null,'height=400, width=400, status=yes, toolbar=no, menubar=no, location=center, scrollbar=no');
}
</script>
</head>
<body>
<form id="form1"
runat="server">
<div align="center">
<p>This is parent Window, 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>
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<script type="text/javascript">
function closechildwindow() {
window.opener.document.location.href = 'Default.aspx';
window.close();
}
</script>
</head>
<body onunload="closechildwindow()">
<form id="form1"
runat="server">
<div>
<p>Now close the child window and notice that parent window
get changed</p>
</div>
</form>
</body>
</html>
|
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|

Subscribe by RSS
Subscribe by Email
1 comments :
Thanks 4 sharing....
i m using this but when close the child window then error generated like this
"Microsoft JScript runtime error: 'window.opener.document' is null or not an object"
my 1st page is city_display.aspx
2nd page is add_city.aspx.