Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 6-Apr-11 5:19am
Edited 6-Apr-11 8:08am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 766
1 OriginalGriff 345
2 CPallini 200
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,795
1 Sergey Alexandrovich Kryukov 5,028
2 CPallini 4,700
3 George Jonsson 3,142
4 Gihan Liyanage 2,450


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 6 Apr 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100