---
title: "What is Viewstate?"  
description: "What is Viewstate?"  
author: "Pushpendra Singh"  
published: 2010-10-25  
updated: 2020-09-15  
canonical: https://www.mindstick.com/interview/112/what-is-viewstate  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# What is Viewstate?

viewstate is oneof the type of asp.net state management. viewstate: used to

save data within postbacks in hidden fields. stored data can

be encrypted for more security via 1) web.config file's

\

```
<Configuration>       <system.web>         <pages viewStateEncryptionMode="Always"/>       </system.web> </configuration>
```

## or 2) page directive:-

\

```
<%@ Page Language="C#" AutoEventWireup="true"CodeFile="Default.aspx.cs" Inherits="_Default" ViewStateEncryptionMode="Always"%>
```

**can set to off:**

1) at entire page level or at specific control level

\

2) at machine or application level in web.config file

## Answers

### Answer by Pushpendra Singh

viewstate is oneof the type of asp.net state management. viewstate: used to

save data within postbacks in hidden fields. stored data can

be encrypted for more security via 1) web.config file's

\

```
<Configuration>       <system.web>         <pages viewStateEncryptionMode="Always"/>       </system.web> </configuration>
```

## or 2) page directive:-

\

```
<%@ Page Language="C#" AutoEventWireup="true"CodeFile="Default.aspx.cs" Inherits="_Default" ViewStateEncryptionMode="Always"%>
```

**can set to off:**

1) at entire page level or at specific control level

\

2) at machine or application level in web.config file


---

Original Source: https://www.mindstick.com/interview/112/what-is-viewstate

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
