View status vs hidden field in asp.net

How can we make a decision for viewstate and hidden field in ASP.NET.

In my case, I use cross-page posting and using the public properties of the first page, I access them on the second aspx page.

After getting the public variable in the second aspx page, I need to access this value on the second page, but as soon as I return to the second page, I can not find this value.

Therefore, to solve this problem, I have two solutions: either use viewstate on the second page, or use a hidden field on the second page.

I can’t decide which one should I use?

+4
source share
3 answers

The approach is exactly the same. The only difference should be the size of the saved information (viewstate uses [sometimes encrypted] base64, while hidden fields use plain text if you yourself do not encode them), and viewstate allows you to make sure that the data has not been changed, due to the default check it has a place.

+8
source

If the data is small and you want to manipulate a value based on some client-side behavior, a hidden field will be useful.

0
source

Difference between view state and hidden field in asp.net

http://royalarun.blogspot.in/2012/03/difference-between-view-state-and.html

Both are used to store the value during postback in asp.net, but

In view state - it is impossible to change the value according to the client code on the ie java script side.
Hidden field - you can change the value according to the client code.

In view mode . You can store more than one value, for example, Datatable and Dataset Hidden Field . You can store more than one value in a hidden field by serializing it.

Viewing status data is encrypted, but the hidden field is not encrypted

0
source

All Articles