Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

ASP.NET - Clearing session variables

Options
  • 17-03-2011 10:31pm
    #1
    Moderators, Home & Garden Moderators, Regional Midwest Moderators, Regional West Moderators Posts: 16,722 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 Posts: 2,790 ✭✭✭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,722 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