1

I have a hidden filed in my master page and there are several pages using this master page.

in first page I will change the hidden filed value and it works fine, but when I change the page that hidden filed will be reset. How can I keep its value on page changing?

Inside Man
  • 4,194
  • 12
  • 59
  • 119

1 Answers1

2

There are several ways to go about this, you could use cookies, or (how I would do it), you could store that value in a session object instead then you can access it anywhere in your application. But if you want to keep using a hidden field in a Master Page, this has been answered several times here before.
Here's a good example.
https://stackoverflow.com/a/10348525/3299157
and here is an example showing how to use session objects: https://stackoverflow.com/a/5282694/3299157

Community
  • 1
  • 1
Ageonix
  • 1,748
  • 2
  • 19
  • 32
  • I don't suggest to use session for several reasons: app pool is recycled often and all values from session are erased, if your app grows bigger and you need to use several servers each of them will have own instance of session and you will have to limit yourself with sticky sessions. – serhiyb Jan 27 '16 at 15:33
  • It depends on his use of this hidden value and the overall application. We really don't have enough info to give a very educated answer. Cookies have their own issues...security, size restrictions, etc. I've written several applications that use session in tandem with stored database values. If session is lost, simply re-retrieve values from the back-end. Not saying cookies don't have their perks...it's all situational. – Ageonix Jan 27 '16 at 15:36