---
title: "EnableViewState in ASP.NET"  
description: "In this blog, I’m explaining the concept of enableviewstate in asp.net.  EnableViewState or ViewStateMode is the property allows automatic state manag"  
author: "Anchal Kesharwani"  
published: 2014-08-14  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/683/enableviewstate-in-asp-dot-net  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# EnableViewState in ASP.NET

In this blog, I’m explaining the concept of [enableviewstate](https://www.mindstick.com/interview/734/what-does-the-enableviewstate-property-signify) in asp.net.\

EnableViewState or ViewStateMode is the [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) allows [automatic](https://www.mindstick.com/forum/145518/what-automatic-repeat-request-arq) [state management](https://www.mindstick.com/blog/219/state-management-in-asp-dot-net) feature enables server control to repopulate without [writing](https://www.mindstick.com/articles/12997/5-essential-tips-on-resume-writing-for-business-analysts) any extra code. This feature is not free however, since the state of a control is passed to and from the server in a hidden [form field](https://www.mindstick.com/forum/158282/how-to-validate-a-form-field-using-jquery). You should be aware of when [ViewState](https://www.mindstick.com/blog/326/viewstate-in-asp-dot-net) is helping you and when it is not.

##### Example

##### Step 1

Write the code in EnableViewState.aspx:

```
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="EnableViewState.aspx.cs" Inherits="_Default" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title>    <style type="text/css">        th {            text-align:left;        }        </style></head><body>    <form id="form1" runat="server">    <div>        <asp:Label ID="lblControl1" runat="server" EnableViewState="false"></asp:Label>        <br />             <asp:Label ID="lblControl2" runat="server" EnableViewState="true"></asp:Label>        <br />         <asp:Button ID="btnCheck" runat="server" Text="Check"  style="height: 26px" />        <br />        <br />             <asp:Label ID="lblMsg" runat="server" EnableViewState="true" Text="Before Post Back"></asp:Label>    </div>    </form></body></html>
```

##### Step 2

Run the [application](https://www.mindstick.com/articles/12824/calculator-application-in-android):

![EnableViewState in ASP.NET](https://www.mindstick.com/blogs/a46cb22d-aace-4f86-ac6c-aab84f2e0062/images/a2c8ada7-9456-4733-ab35-90dcc66ed2b2.png)

##### Step 3

After click on Check button:

![EnableViewState in ASP.NET](https://www.mindstick.com/blogs/a46cb22d-aace-4f86-ac6c-aab84f2e0062/images/0e3c3779-c6d0-42b8-96e8-ebce7fd4853f.png)

In this example one [label control](https://www.mindstick.com/articles/301/a-label-control-in-vb-dot-net) disable EnableViewState and another label enable EnableViewState.

---

Original Source: https://www.mindstick.com/blog/683/enableviewstate-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
