I can disable viewstate of each control, but not entire page.
Is there a way to disable viewstate in whole page?
I can disable viewstate of each control, but not entire page.
Is there a way to disable viewstate in whole page?
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"/>
private void Page_Init(object sender, System.EventArgs e)
{
this.EnableViewState = false;
}
You can set Page.EnableViewState="false"
But no matter what there will be some very small ViewState footprint on any .aspx page you create.
You can do it in the page declaration:
<%@ Page EnableViewState='false' %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" EnableViewState="false" %>