This is probably beginner’s question, but if I need to keep variable’s value between requests in web forms I have quite a bit of options:
- write hidden input element and carry value there
- keep value in Session dictionary
- keep value in ViewState dictionary
- probably something else I’m not aware of
So what is the right way in web forms? (I need to keep value between requests to the same page)
You should read this: http://msdn.microsoft.com/en-us/library/75x4ha6s.aspx. The MSDN articles list all the possible way you could save the state of you session.
If you just want to save the state of your controls between postback, you should use ViewState.