Last post Nov 10, 2014 10:31 AM by Siva Krishna Macha
Nov 10, 2014 07:26 AM|davidinho|LINK
is there a way to disable the viewstate of a single control only for an event?
I'll explain, there is a grid that contains a large amount of data, now I would like to disable the viewstate of this control only when the user click on a specific button(that send information to the server)
Is there a way to do this?
Nov 10, 2014 10:31 AM|Siva Krishna Macha|LINK
You can selectively disable viewstate for a control by using EnableViewState (before 4.0) or ViewStateMode (from 4.0 onwards).
This article explains the two tags in detail:
However, as this is control's property - you can access this control from code (in C# or VB - code behind) and set the flag value to false based on your condition. You could try it out and let us know if you are facing any issue. Reference:
// Set EnableViewState to false to disable saving of view state
myControl.EnableViewState = false;
Note: Though ViewState is disabled, you can still see some trace of it, because the data is required during form post for the server to understand submitted values by the user for a control. For instance, see this post: