Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

ASP.NET - Clearing session variables

  • 17-03-2011 10:31PM
    #1
    Moderators, Home & Garden Moderators, Regional Midwest Moderators, Regional West Moderators Posts: 16,716 Mod ✭✭✭✭


    Hi
    Looking for some advice please.

    Have a site that has a search page. I store the search criteria in a session variable so when the user searches and clicks edit to go to an EDIT page that when they click "return to search" on the EDIT page that it holds the criteria and the search results.

    Now, if the person goes away from that page either view other "side" menus or the back button and then later on, return to the Search Page I don't want the criteria to appear.

    I know there is an unload function but it triggers when the page loads so not ideal!

    Is there a method I can trigger when the person hits the "Back" button or the side menus.

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    yop wrote: »
    Hi
    Looking for some advice please.

    Have a site that has a search page. I store the search criteria in a session variable so when the user searches and clicks edit to go to an EDIT page that when they click "return to search" on the EDIT page that it holds the criteria and the search results.

    Now, if the person goes away from that page either view other "side" menus or the back button and then later on, return to the Search Page I don't want the criteria to appear.

    I know there is an unload function but it triggers when the page loads so not ideal!

    Is there a method I can trigger when the person hits the "Back" button or the side menus.

    Thanks

    No, I'm afraid I don't think there is.

    I would approach this by adding some code to your base page which checks if it's not the search page, and the session variable isn't Null, then clear the session variable.

    You could then call this in the page load event of the basepage


  • Moderators, Home & Garden Moderators, Regional Midwest Moderators, Regional West Moderators Posts: 16,716 Mod ✭✭✭✭yop


    John_Mc wrote: »
    No, I'm afraid I don't think there is.

    I would approach this by adding some code to your base page which checks if it's not the search page, and the session variable isn't Null, then clear the session variable.

    You could then call this in the page load event of the basepage

    Thanks, excellent suggestion! :) I will do that.


Advertisement