Leaving a Page

B

brian

Is there an event that can be fired when a user navigates
to another page. If a user is at page 'A' and navigates
to page 'B' I want code to excute. I am not looking for
browser exits.

Thanks
 
P

Patrice

Client side you could perhaps use the onunload for the body tag (you won't
distinguish between exit and navigating to another page).

It's always better to describe also why you need to do that so that someone
can suggest a new direction if possible...
 
B

brian shannon

Thanks Patrice

I have my web.config file set for 20 minute timeouts. I use session
variables throughout my page.

If I assign a session variable in certain pages I only need that
variable for the time that the user is on the page. For instance, I
have a dataset stored in a session variable that is only used for 1
page. The user will make numerous postbacks to the page so I don't want
to fill the dataset each time.

But once the user leaves the page I am done with the dataset so I would
like to clear it out of memory immediately. I can't clear the variable
because I don't know when the user is done with the page.

Is there a better way of storing this dataset? Should I be cacheing it.
I have never used cacheing in my apps so maybe I should if it would work
better in this type of situition.

Thanks


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
J

John Saunders

brian shannon said:
Thanks Patrice

I have my web.config file set for 20 minute timeouts. I use session
variables throughout my page.

If I assign a session variable in certain pages I only need that
variable for the time that the user is on the page. For instance, I
have a dataset stored in a session variable that is only used for 1
page. The user will make numerous postbacks to the page so I don't want
to fill the dataset each time.

But once the user leaves the page I am done with the dataset so I would
like to clear it out of memory immediately. I can't clear the variable
because I don't know when the user is done with the page.

You will have to decide what constitutes "done". This is a lot easier if
your page has something like a "Done" button, whose click event would signal
that the user is done. Otherwise, you can find yourself in trouble if the
user does something like use the back button or create a second browser
window.
 
J

Justin Beckwith

One option is to call a new window on page unload, that performs the
Session.Abandon();

<body onunload="window.open('killsession.aspx')">

have killsession.aspx automically kill the session and close itself.
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top