How to close a window in asp.net?

Mike521

Freshman
Joined
May 3, 2004
Messages
27
Is there a built in way to do this? I tried using a javascript but for some strange reason it's giving me hell, saying that an if block must have a terminating "end if" statement. The end if is there, however I think the program is seeing the window close before the end if, and getting screwed up.

I also tried window.close() but it said window undefined.

Any ideas?

Here's the code, it's not complex at all:

Code:
<Script Runat="Server">

Sub Page_Load

	 if ( IsPostBack ) and ( chkNoShow.Checked ) Then
		Response.Cookies("noShow").Value = "false"
		Response.Write("<script language=""JavaScript"">window.close();</script>")		
	end if

End Sub

</script>
 
I do not think it would be different than old asp:
<script>

var vWin
function openwindow(){
vWin = window.open( 'http://www.google.com' );
}

function tWin() {
if (vWin.closed) {
document.location = document.location;
}
else {
setTimeout("tWin()", 500);
}
}

</script>
 
shahab said:
I do not think it would be different than old asp:
<script>

var vWin
function openwindow(){
vWin = window.open( 'http://www.google.com' );
}

function tWin() {
if (vWin.closed) {
document.location = document.location;
}
else {
setTimeout("tWin()", 500);
}
}

</script>

I'm a bit confused over what that code does.. it seems to track a remote window, right? I need to close the current window.

This project opens up a window with a checkbox. If the user clicks the checkbox, the script plants a cookie then closes itself (the popup window)..
 
Back
Top