Link to home
Start Free TrialLog in
Avatar of pmac38CDS
pmac38CDS

asked on

Close aspx page opened in a pop up window

I was wondering how can I close a aspx page that has been opened in a pop up window. I have an html page with a button when clicked opens the html page in a pop up window. When the submit button is clicked after processing the information I would like to close the pop up window. How can I go about doing this ?
Avatar of Luis Pérez
Luis Pérez
Flag of Spain image

Can you post the code in which you're opening the popup?
To close the window popup from within it's own client code use:

window.close();

To close it from parent window client code you should open the child with a reference:

childWindow = window.open(....

and after submittin use:

childWindow.close();
pls chk the link for the answer  closing a popup form
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pmac38CDS
pmac38CDS

ASKER

Yes I would like to implement this in the aspx.cs file. How can I go about doing this ?

Thanks,
Aditya
Check Page.ClientScript.RegisterStartupScript() on this page : http://msdn.microsoft.com/en-us/library/aa479390.aspx

On the popup page :

    protected void Page_Load(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", "window.opener.signalPostback();", true);
    }

Open in new window


In the header of the main page, no change :
<script language="javascript" type="text/javascript">
 	var n = 0;
	function signalPostback() {
		alert(n++);
		if(n>1) {
			alert("second postback/refresh, we close it");
			a.close();
		}
	}
</script>

Open in new window

I had to tweak my aspx to implement the solution.