Anyname Donotcare Anyname Donotcare - 28 days ago 7
Ajax Question

hidden field vs viewstate

What is the difference when using


  • Hidden field vs View state?

  • When to use each one ?

  • Which one more secure?

  • Which is better in performance?

  • what are the alternatives?


Answer

ViewState is stored in a hidden field and it contains information about the entire page. It can also be encrypted. Because the view state is always sent to the codebehind when performing Postbacks it is very practical as you always get the values. The drawback is that it can get really large if you start putting much information inside it and performance could start to suffer. For example in some AJAX requests you want to only send some small information to the server and if you used UpdatePanels the entire ViewState will be sent and it will contain information that is not necessary.