Possible Duplicate:
How to share a variable between C# and JavaScript?
I am enhancing a C# ASP.NET web app that has two important divisions in the HTML. Two menu options are available to cause one to be hidden and the other to be unhidden. Let’s call them Page One and Page Two.
The problem is that some things on the page cause a postback, which causes a total refresh and forces the default to be Page One. Also we automatically do a refresh every five minutes to get new page content. If the user happens to be viewing Page Two when the refresh occurs either automatically or because of a postback after the user has clicked on certain things, the page automatically goes back to Page One.
Long term the solution is to properly use AJAX. For now I need a quick and dirty way to remember which page the user is on when a refresh occurs and then put him back on that page upon refresh.
Can I create a variable on the server side in C# that I can interrogate on the client side with JavaScript? Technically the server does not need to know which page div is displayed in the browser if I can somehow make the client remember it from page refresh to refresh. Is there a way to do that?
Forgive me if this seems elementary. I have many years of programming experience (mostly C/C++ in the MS-DOS and Unix worlds), but not very much in the ASP.NET environment.
If you are using meta tag to refresh the page
<meta http-equiv="refresh" content="600"/>, then you should pass a tab/page id along with the url:Also add this attribute when you send any postback to the page.
Now, you just need to read a value of this attribute on the server side and replace it in the meta refresh tag: