When a user leaves a page it fires of the Page_Load event again. How can I tell in code_behind that this is happening so in can avoid running the custom functions as the code in the Page_Load does not really need to be ran when leaving the page?
Share
What do you mean by leaving a Page? Closing the browser or clicking Back button on browser? Or moving to another Page?
Page_Loadmethod is fired when on Loading Page or when Postback occurs on the same Page, but not leaving it.Before you start any operations, you can (and you should) ensure that client is still connected and use
HttpResponse.IsClientConnectedproperty.The IsClientConnected property returns false when the following conditions are true:
http://msdn.microsoft.com/en-us/library/system.web.httpresponse.isclientconnected.aspx
EDIT
Switching tabs usually fires normal Postback, to detect it you should use: