Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to close child window from parent window button click in asp.net?
Posted
Comments
F-ES Sitecore 22-Jul-15 10:56am    
Google the question and you'll find an answer.
ZurdoDev 22-Jul-15 11:20am    
How is the child window being opened? Click improve question and show some relevant code.
Sathish km 22-Jul-15 23:49pm    
String open = "window.open(\"AJVErrorlog.aspx?ProjectCode=" + "1200" + "&ScheduleCode=" + EncrytedString(Session["ScheduleId"] as string) + "\",'mywindow', 'height=750,width=1200, menubar=0, resizable=yes')";
ScriptManager.RegisterStartupScript(this.ctbUpdatePanel, this.ctbUpdatePanel.GetType(), "focus", open, true);


i tried this method, but

1 solution

This is Window.close(). Note that window.close() would work on a current window; but 1) it won't work in all cases and 2) not what you need.

"Parent" and "child" probably means that you created some window from what you call "parent". When you do so, you will receive the window object reference for the newly created window. You will need to preserve this reference to use the new window object later on, and to close it:
JavaScript
var myChild = window.open(/* ... */)

// and later

myChild.close()


Please see:
https://developer.mozilla.org/en-US/docs/Web/API/Window/open[^],
https://developer.mozilla.org/en-US/docs/Web/API/Window/close[^].

Note that creation of popup windows can be blocked by the browser.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900