ASP.NET Tutorial

.NET Framework

ASP.NET Introduction

ASP.NET Web Forms

Standard Controls

Label Control

TextBox Control

Image Control

Button Controls

Redirecting User

Using HyperLinks

RadioButton Control

RadioButtonList

CheckBox Control

CheckBoxList Control

DropDownList

ListBox Control

ImageMap Control

Event-Driven Programming

ASP.NET Page Structure

IsPostBack

Master Page

View State

Visibility of Controls

Formatting Controls

Applying CSS

Dynamic CSS

Using Style Class

Themes and Skins

Panel Control

PlaceHolder Control

AdRotator Control

Calendar Control

File Upload, Virtual Path

Validation Controls

Page Navigation

User Control

Separating Code-Presentation

Overview of ADO.NET

Data Binding

DataBinding List Control

View State

The HTTP protocol is a stateless protocol means when you request a page again the value assign to the control is lost. To retain value of a control view state is used. By default, almost all ASP.NET controls automatically preserve view state.
View State is implemented as a hidden form field known as _VIEWSTATE that is automatically created in a Web Forms page. If you look at the source code of the HTML page in the browser, you will observe that a hidden form field is added to the page. It should look like:
View state is preserved only if you post form data to the same page. If you visit another Web page through a link or post the form to another page, the view state information is lost.
View state is useful in form validation scenarios. Suppose a user has entered a lengthy form incorrectly or incompletely. You wish to re-display the form to the user with an error message so that the user can complete the form correctly. In this situation, you can show the data that the user has already entered in the form so that the user does not have to fill the whole form again. This can be made possible through view state.
But, sometimes you may wish to disable view state for a certain control or for a page. If the view state contains a lot of data for instance, it can slow down the rendering of the page.

Disabling View State for a Control

ASP.NET controls have an EnableViewState property, which takes a Boolean value. You can use this property to enable or disable the view state for the control.

Disabling View State for a Page

You can disable the view state for an entire page if the page has a lot of data and you do not need view state. This enables the page to be re-loaded quickly. You can enable or disable view state for a page using a Page directive.