How can I find user click Back Button at IE?
-
When my asp.net code page open, there are 2 dataset object created. I need to dispose these datasets when user click back button. How can I find user click back button at IE menu? Please let me know.
You cannot directly detect the press of any browser button. You do have a couple of options for cleaning up, however. First, in
Global.asax
, there is an event handler mapped for you calledSession_End
that will execute when the user's session expires. You could run your clean-up code there. You could instead store your dataset objects in theCache
object of the current Http context. By doing so, you could set some cache policies that would be more aggressive in expiring the items. Note that this cache is shared accross user sessions, so you would want to use a key that is unique, such asSession.SessionId
, to prevent sessions from interacting. Another option is to use javascript to handle theonunload
event for thebody
object. You could send an asynchronous request to a web service method on the server to perform your clean-up code for you. Note that theunload
event will run whenever the page is unloaded from the browser, including when you perform a postback or navigate to another page in your site, so it can be difficult to determine when, exactly, you want to run your clean-up. I hope that helps to get you started. :)--Jesse
"... the internet's just a big porn library with some useful articles stuck in." - Rob Rodi