# VBForums CodeBank > CodeBank - ASP / ASP.NET / MVC / Web API >  How to Completely Remove Viewstate in your ASP.NET page

## mendhak

VB Code:
Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewState As Object)
       End Sub
     Protected Overrides Function LoadPageStateFromPersistenceMedium() As Object
        Return Nothing
     End Function
     Protected Overrides Function SaveViewState() As Object
         Return Nothing
     End Function

----------


## koolprasad2003

here is another code



```
To disable a pages View State, add the code below in the Page class of the page. In this example, the pages class name is ShowOrdersTablePage. 
C#: 

public ShowOrdersTablePage()
{
    this.Init += new EventHandler(Page_Init);
}
 
private void Page_Init(object sender, System.EventArgs e)
{
    this.EnableViewState = false;
}
 


Visual Basic .NET: 

' Disable the View State in the page.M
Private Sub MyPage_Init_DisableViewState(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Init
    Me.EnableViewState = False
End Sub
```

thankx
koolprasad20003 :Smilie:

----------


## mendhak

Hmm, I should mention that the first post completely removes all viewstate (you end up with a hidden field on the page called __viewstate, but no value).  I must have made this thread in a rush, I will update it now.  :Smilie:

----------


## Sherin

*ViewState* can be disabled at the following levels:
1. Control Level.
2. Page Level.
3. Application Level.

(1) *Disable ViewState at Control Level*

ViewState can be easily disabled for a particular control by setting EnableViewState property to False.


```
<asp:TextBox ID = "txtName" runat="server" EnableViewState = "false" />
```

(2) *Disable ViewState at Page Level*
ViewState can be disabled for the whole Page i.e. all controls on the Page by setting the EnableViewState property to False in the @Page Directive.


```
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" EnableViewState = "false" %>
```

(3) *Disable ViewState at Application Level*
ViewState can be disabled for the whole Application i.e. all Pages by setting the enableViewState property to False in the pages section of the Web.Config file.


```
<system.web>
    <pages enableViewState="false">
    </pages>
</system.web>
```

----------

