Page Closure

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.
 
C

Cowboy \(Gregory A. Beamer\)

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!
**********************************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top