view state in asp.net
I can disable viewstate of each control, bu开发者_如何转开发t 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"/>
You can do it in the page declaration:
<%@ Page 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.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" EnableViewState="false" %>
精彩评论