问题描述
我在我的网站上使用了第三方服务器端控件(ASP.NET的Teleeled RadControls).菜单控件具有复杂的结构,这使视图状态的大小膨胀,从而影响加载时间.我不知道viewstate的详细信息,只是Web服务器使用它来跟踪控件值.
I am using third party server-side controls on my website (Telerik RadControls for ASP .NET). The menu control has a complex structure which is bloating the size of the viewstate affecting load times. I am not aware of the details of viewstate except that it is used by the web server to keep track of control values.
由于我网站上的大多数页面仅显示,是否可以禁用未接受用户输入的视图状态?无论如何,所有动态项目都会在页面加载时重新生成.
Since most of the pages on my website are display only, is it possible to disable the viewstate where user input is not taken? All dynamic items are being regenerated on page load in any case.
推荐答案
如果使用的是asp.net 4,则可以使用ViewStateMode
属性来控制控件的视图状态生成. ViewStateMode
If you're using asp.net 4, then you can use the ViewStateMode
property to control viewstate generation for controls. ViewStateMode
如果不使用asp.net 4,则可以在页面或控件级别打开视图状态.
If you're not using asp.net 4, then you can turn of viewstate at the page or control level.
<%@ Page Language="C#" EnableViewState="false"%> //disabling viewstate.
http://msdn.microsoft .com/en-us/library/system.web.ui.page.enableviewstate.aspx
这篇关于是否可以在ASP .NET中禁用ViewState?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!