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
Which is faster viewbag or viewdata?
What are the 3 types of web?
What is semantic gap?
What are the new features implemented in ASP.NET?
What type of code, client-side or server-side, is found in a code-behind file of a Web page?
Where do the cookie state and session state information be stored?
Can the dictionary object be created in client?s scope ?
If you want to write your own dot net language, what steps you will you take care?
How can you register a custom server control to a web page?
Explain how asp.net page works?
Can you explain how ASP.NET application life cycle and page life cycle events fire?
Which is the best institute to learn Microsoft Technologies and the faculty if you Know?
What are main return types supported in Web API?
Explain what are webservices?
What is difference between mvc and asp.net? : Asp.Net MVC