Click here to Skip to main content
15,920,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am opening a popup(a popup page) window from a page through window.open now I want that when I close that popup window at the same time a method on parent page should be called? I m using this code to open popup
string newPage = "TestPopUp.aspx";
ScriptManager.RegisterStartupScript(Page, GetType(), "onClick", "window.open('" + ResolveClientUrl(newPage) + "', 'UpdateRecord', 'toolbar=no,location=center,status=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=300,top=200, left=200');", true);


and this code to close popup
ScriptManager.RegisterStartupScript(Page, this.GetType(), "onAddNew", "window.close();", true);

Now tell me can I call my server side parent page method BindGridview() at the time of closing this popup.
Thanks in advance.
Posted

use this inside "Not PostBack" IF Statement..

C#
if(!IsPostBack)
{
   if(Request.QueryString["fromChild"] != null && Request.QueryString["fromChild"]=="1")
   {
      BindGridView();
   }
} 
 
Share this answer
 
try this..

In your child window write one javascript function for close..

JavaScript
function close()
{
     window.opener.location.href = 'http://parentPage.aspx?fromChild=1';
     self.close();
}


call this function on close..

C#
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "onAddNew", "close()", false);



In your parent page PageLoad check the query string..

C#
if(Request.QueryString["fromChild"]=="1")
{
    BindGridView();
}


hope this helps..
Vote it if solved your problem
 
Share this answer
 
v4
@Karthik Harve
this solution is not working when I click on update button to close popup. The pop up is not closed rather a string "close()" is appeared on the popup screen :(
 
Share this answer
 
Comments
Karthik Harve 9-Dec-11 7:20am    
I have updated my solution..
touseef4pk 9-Dec-11 7:49am    
@karthik
It is working somewhat and PageLoad of parent is being called when popup is closed but now it keeps executing PageLoad in a loop again and again. and giving this error "Microsoft JScript runtime error: Permission denied" and javascript message box appears of "Stack Overflow" ????
SQL
@karthik
It is working somewhat and PageLoad of parent is being called when popup is closed but now it keeps executing PageLoad in a loop again and again. and giving this error "Microsoft JScript runtime error: Permission denied" and javascript message box appears of "Stack Overflow" ????
 
Share this answer
 

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