What does the "EnableViewState" property do? Why would I
want it on or off?

Answer Posted / satish v itagi

Web page is a stateless entity. To preserve data between
postbacks dot net provided to containers viz. ViewState and
Session.

Viewstate enables persistence of data across post backs in
web forms of dot net (web pages). The data is stored in
hidden field/s of the page. Hence data travels across
media between server and client making loading and un-
loading slow. The advantage is every page will have its
own viewstate data. Normally web controls will have
viewstate enabled. If viewstate is turned off, other data
also can be saved in viewstate.

Objects have to be serialised before putting in viewstate.
While accessing methods and properties of an object the
object has to be properly type casted.

At times, viewstate of a page can get corrupted, requiring
the whole application to be re-started. It is not good
idea to keep large objects in viewstate.

If performance is the issue turn off viewstate, if
persistence is the issue and you have small to medium sized
data enable viewstate.

Keeping state in Sessions is also a better solution.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the three parts of an http response?

534


Which is better asp.net or php?

536


What is asp.net file?

633


How many types of validation are there?

527


What is a postback url?

495






What are the uses of reflection?

579


What are ASHX files?

603


What are the different methods of session maintenance in asp.net?

542


Are cookies stored on server or client?

507


How many types of session state management options available in asp.net?

542


What are the components of ado.net?

536


Can anyone please tell me that the question posted on this website are Sufficient for the interview with 2+ year experience in .net

1507


How do you identify that the page is postback?

541


Explain the use of view state?

566


List the asp.net validation controls?

527