Raheel Khan Raheel Khan - 18 days ago 8
ASP.NET (C#) Question

Is it possible to disable ViewState in ASP .NET?

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.

Answer

If you're using asp.net 4, then you can use the ViewStateMode property to control viewstate generation for controls. ViewStateMode

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