ViewStateMode禁用,但仍然得到的ViewState元 [英] ViewStateMode Disabled but still getting ViewState element

查看:123
本文介绍了ViewStateMode禁用,但仍然得到的ViewState元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET 4.0 WebForms的网站,我有母版,因此设置为 ViewStateMode =已禁用随着内容占位符被设置类似。

当我查看我的网页我仍然会看到一个ViewState字段渲染,然后我试图加入ViewStateMode =已禁用,以页面级别也但这并没有改变任何东西。

解决方案

我不知道该框架4 ViewState的最新变化,但你必须考虑到ViewState字段呈现给客户由两部分组成: ViewState的本身了ControlState-。

在了ControlState-总是发送到客户端上的ViewState字段不管你已经启用的ViewState与否。

所以,你可以期望大大减少发送到客户端的ViewState字段的大小,但不能完全将其删除。

控制状态是最小的事情,控制需要在回传坚持以正常工作。

  
    

控制状态

         

在除了浏览状态时,ASP.NET支持控制状态。该页面使用控制状态持续下去必须回发之间被保留,即使视图状态的页​​面或控制禁止控制信息。像视图状态,控制状态被存储在一个或多个隐藏字段。

  

<一个href="http://msdn.microsoft.com/en-us/library/bb386448.aspx">http://msdn.microsoft.com/en-us/library/bb386448.aspx

I have a ASP.NET 4.0 webforms site where I have the MasterPage so it is set to ViewStateMode="Disabled" along with the content placeholders being set similarly.

When I'd view my page I'd still see a ViewState field rendered, I then tried adding the ViewStateMode="Disabled" to the page level also but that didn't change anything.

解决方案

I'm not aware of latest changes on ViewState for the framework 4 but you have to take into account that the ViewState field rendered to the client has 2 components: ViewState itself and ControlState.

The ControlState is ALWAYS sent to the client on the viewstate field no matter if you have enabled ViewState or not.

So you can expect to drastically reduce the size of the viewstate field sent to the client but not completely remove it.

Control state are the minimal things that a control need to persist across postbacks in order to work as expected.

Control State

In addition to view state, ASP.NET supports control state. The page uses control state to persist control information that must be retained between postbacks, even if view state is disabled for the page or for a control. Like view state, control state is stored in one or more hidden fields.

http://msdn.microsoft.com/en-us/library/bb386448.aspx

这篇关于ViewStateMode禁用,但仍然得到的ViewState元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆