Click here to Skip to main content
15,886,035 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
I am having a problem while refreshing my parent window.

I have a webform and I am using a viewstate on this form. on the viewstate's 3rd activeform I have a table. In a row of this table when the radiobutton's value is equal to No(I am doing an autopostback here) a popup window opens. Here on the popup window I make user to select some items in the checkbox list and carry the data to a textbox in the parent form. Till here everything is fine.

My problem is I can not close the popup. What happens is;

I can successfully pass the data to my parent window, refresh it but the popup windows closes and it popups again.

I am trying to do it with this code;

Page.RegisterStartupScript("CLOSE", "<script language="'javascript'">window.opener.document.forms(0).submit();self.close();</script>");

What I also tried;

ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.onunload = CloseWindow();");


Page.RegisterStartupScript("CLOSE", "<script language="'javascript'">window.opener.location.reload();self.close();</script>");


Page.RegisterStartupScript("CLOSE", "<script language="'javascript'">window.opener.location.href = window.opener.location.href;self.close();</script>");


Page.RegisterStartupScript("CLOSE", "<script language="'javascript'">window.opener.history.go(0) = window.opener.location.href;self.close()</script>");
These three doesnt work the way I want. They either popup the popup window again, or close the popup, reload the parent but then parent goes back to Viewstate's active viewindex 1 instead of staying in 3.

Any ideas how can I fix this? Thanks
Posted
Updated 6-Apr-11 8:08am
v3

1 solution

parent goes back to Viewstate's active viewindex 1 instead of staying in 3.= You have to set the active view (ActiveIndex) on each post back.

If you register the script on the page load it will execute on each time postback regardless which view. Use the IsPostback property of the page and necessary conditions to execute the startup script.
 
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