ASP.NET:为什么控制状态不能被禁用 [英] ASP.NET: Why control state cannot be disabled

查看:121
本文介绍了ASP.NET:为什么控制状态不能被禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道ASP.NET不允许禁用控制状态。

I know ASP.NET doesn't allow to disable control state.

有谁知道的为什么?我GOOGLE了很多,但只看到它是不可能的,但没能找到为什么?

Does anybody know why? I've googled a lot but only saw it is not possible, but was not able to find "WHY?"

任何对此的思考会受到欢迎!

Any thoughts on this would be welcome!

P.S。在我的特殊情况下,我需要把很多物品到不会被用于服务器端事件的下拉列表。而不是仅仅禁用控制状态,我需要写我自己的自定义DropDownList的...:(

P.S. In my particular case I need to put a lot of items into a dropdown list that will NOT be used for server side events. Instead of just disabling control state I need to write my own custom DropDownList... :(

推荐答案

控制状态从视图状态分离出来,使视图状态可以在不关键的功能被禁用。从理论上讲,控制状态应该包含一切必要的服务器控件才能正常工作。

Control state was separated from view state so that view state could be disabled without breaking critical functionality. In theory, control state should contain everything necessary for the server control to function properly.

控制状态,在ASP.NET 2.0中引入的,
  类似的视图状态,但功能独立的视图状态。一个
  页面开发人员可以禁用视图状态页面或一个
  单独的控制性能。然而,控制状态不能
  禁用。控制状态被设计用于存储一个控制的基本
  数据(如一个寻呼机控制的页号),该上必须有
  回发使能控制的功能视图状态,即使
  被禁用。

Control state, introduced in ASP.NET version 2.0, is similar to view state but functionally independent of view state. A page developer can disable view state for the page or for an individual control for performance. However, control state cannot be disabled. Control state is designed for storing a control's essential data (such as a pager control's page number) that must be available on postback to enable the control to function even when view state has been disabled.

http://msdn.microsoft.com /en-us/library/1whwt1k7(v=vs.100).aspx

不过... ASP.Net做的不好使这种区别,并禁用视图状态的确会破坏某些服务器控件尽管强制控制状态。

However...ASP.Net does a poor job of making this distinction, and disabling view state will indeed break certain server controls despite the mandatory control state.

在您的情况下,禁用视图状态下拉列表应该删除绝大多数国家的数据;控制状态通常是与视图状态下拉关闭相当小。我建议首先尝试它写自己了。

In your case, disabling view state for the dropdown list should remove the vast majority of state data; control state is usually quite small for a dropdown with view state disabled. I suggest trying it first before writing your own.

这篇关于ASP.NET:为什么控制状态不能被禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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