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 ?
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();
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes I would like to implement this in the aspx.cs file. How can I go about doing this ?
Thanks,
Aditya
Thanks,
Aditya
Check Page.ClientScript.Register StartupScr ipt() on this page : http://msdn.microsoft.com/en-us/library/aa479390.aspx
On the popup page :
In the header of the main page, no change :
On the popup page :
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", "window.opener.signalPostback();", true);
}
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>
ASKER
I had to tweak my aspx to implement the solution.