Page Closure

  • Thread starter Thread starter JezB
  • Start date Start date
J

JezB

1) How can I force page closure from server side c# code ? (eg. on my own
Close button event).

2) I want to do some session variable cleanup when the user is finished with
my page. Where is the best place to do this, considering that generically a
user may a) Navigate away from the page, b) Close the window manually, or c)
Close the window implicitly via my own Close button event (see Q.1). I want
to make sure the session cleanup code is fired in all these conditions.
 
You cannot truly close a page from server side, but you can write out a
JavaScript block on the client like so:

Response.Write("<Script language=\"JavaScript\">");
Response.Write("window.close();");
Response.Write("</Script>");

Before writing out the code, you can abandon session. If you have a logon,
you do not have to close the window, per se, as Session.Abandon will drop
them back to the logon page.

NOTE: When you send window.close, the user will get a message box telling
them someone is trying to close the window, which they can refuse.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Back
Top