views:

65

answers:

5

I can disable viewstate of each control, but not entire page.

Is there a way to disable viewstate in whole page?

+5  A: 

Set Page.EnableViewState to false. This can be done either in the code-behind or in the page directive:

<%@ Page EnableViewState="false" %>

You can also disable ViewState at the application level by setting the enableViewState attribute of the pages node to false in your web.config:

<pages enableViewState="false"/>
Andrew Hare
+1  A: 
private void Page_Init(object sender, System.EventArgs e)
{
    this.EnableViewState = false;
}
Syed Tayyab Ali
+1  A: 

You can set Page.EnableViewState="false"

But no matter what there will be some very small ViewState footprint on any .aspx page you create.

brendan
+2  A: 

You can do it in the page declaration:

<%@ Page EnableViewState='false' %>
Keltex
@keltex: double quotation..
Syed Tayyab Ali
@Syed Tayyab Ali - single quotes work fine.
Keltex
A: 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" EnableViewState="false" %>
Rune