ViewStateMode 已禁用但仍获取 ViewState 元素

ViewStateMode Disabled but still getting ViewState element(ViewStateMode 已禁用但仍获取 ViewState 元素)
本文介绍了ViewStateMode 已禁用但仍获取 ViewState 元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ASP.NET 4.0 webforms 站点,我有 MasterPage,所以它被设置为 ViewStateMode="Disabled" 以及类似设置的内容占位符.

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.

当我查看我的页面时,我仍然会看到呈现的 ViewState 字段,然后我尝试将 ViewStateMode="Disabled" 添加到页面级别,但没有任何改变.

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.

推荐答案

我不知道框架 4 对 ViewState 的最新更改,但您必须考虑到呈现给客户端的 ViewState 字段有 2 个组件:ViewState 本身和 ControlState.

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.

无论您是否启用了 ViewState,ControlState 总是在 viewstate 字段上发送给客户端.

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 contains the minimal things that a control needs to persist across postbacks in order to work as expected.

控制状态

除了视图状态,ASP.NET 还支持控件状态.页面使用控件状态来保存必须在回发之间保留的控件信息,即使页面或控件的视图状态被禁用.与视图状态一样,控件状态存储在一个或多个隐藏字段中.

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 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)
Bind multiple parameters from route and body to a model in ASP.NET Core(在ASP.NET Core中将路由和主体中的多个参数绑定到一个模型)
Custom model binding in AspNet Core WebApi?(AspNet Core WebApi中的自定义模型绑定?)
How to minify in .net core mvc view?(如何在.Net核心MVC视图中缩小?)