Closing browser window from server side in asp.net

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I hope some one has an answer to this.

I have a button in an aspx page . On server click of this button, i perform
some operation. Once the operation is performed i want to close this window
automatically.

Pls help
Sileesh
 
i don;t think you can literally close a browser from a server side script.
what you can do instead is to pass a client side script after you've done
your process on the server side..

sample..
private sub Button1_Click()

--do your server side processing here.

--after you're done load the close window script
Dim strscript As String = "<script
language=javascript>window.top.close();</script>"
If (Not Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript", strscript)
End If

end sub

hope this helps..
 
HI Allan

Thx. It works great.

Allan said:
i don;t think you can literally close a browser from a server side script.
what you can do instead is to pass a client side script after you've done
your process on the server side..

sample..
private sub Button1_Click()

--do your server side processing here.

--after you're done load the close window script
Dim strscript As String = "<script
language=javascript>window.top.close();</script>"
If (Not Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript", strscript)
End If

end sub

hope this helps..
 
Back
Top