ViewState is optional but useful. What is a ViewState is all the changes that occur in a control on the SERVER SIDE side. So, if you assign text to a label, and you want this text to be saved without having to reassign it with every postback, then you want to save it. Another example, when I always leave ViewState on, is something related to the data.
However, there are times when it is useful to disable ViewState for the same reason. For example, one place where I always disable ViewState is the MESSAGE label. Thus, when I have to print a message to the user (which should appear only once, and then leave), I just add the text to the shortcut and then forget about it. During the next PostBack, the label will automatically return to the text that is contained in the ASPX declaration for this control (in this case, an empty line).
Now note that this has nothing to do with the collection of forms, which are values submitted to IIS during PostBack. A collection of forms sends values that the user enters into form elements (text fields, check boxes, jerks, etc.). These .NET will be filled in the appropriate place - and this will happen after the ViewState has been processed.
Thus, if you send a text field with the phrase "hi there" to the client, the user changes it to "See ya" and then submits the form, then that will have a text field at the time the Page_Load event occurs, the text field with "See ya" in the TEXT attribute.
source share