How to clear the session variable in asp.net design source file
Someone asked on Stack Overflow:
Session[“pageIndex”] this is my variable which is used in all aspx.cs pages
I used
$('#btn_click').click(function(){ sessionStorage.removeItem('pageIndex'); )};to clear the session variable in design source file but it doesn’t works
help me thanks in advance
I posted the following answer, which was chosen as the accepted answer:
I recommend you throw the page number into the query string, then in the Page_Load event, you check for it. If its there, you go to that page directly, otherwise you load the first page.
This should support browser back button functionality taking you to the correct page.
The issue you’re experiencing is that ASP.NET is letting you change the page content without changing the url.
Notable comments
Nate (0 upvotes): @SatG_shanu I recommend that you revert the edit to your question here, and post a new question.
Originally posted on Stack Overflow — 0 upvotes (accepted answer). Licensed under CC BY-SA.