Last post May 28, 2009 04:35 PM by XIII
May 22, 2009 04:08 PM|Nowman|LINK
In all of my web user controls that I need to persist information during postback, I always create a ViewState Property. I just watched the video #27 of the General ASP.Net learn and they suggest to use the "Control State". This is the first I have ever
heard of this and I am confused on why you want to use the Control State over the View State. Can anyone please shed some light on this for me? I take it that the Control State is not stored in the ViewState when rendered to the page? I'm lost on this Control
State stuff!! :)
May 22, 2009 04:32 PM|XIII|LINK
when you use viewstate in your controls a developer using your control could opt to turn viewstate off which could end up that your control doesn't behave properly anymore. Controlstate on the other hand can't be turned off by a developer using your control.
However you as a control designer should make sure that you don't abuse this feature. Only put the ultimate necessary stuff inside control state.
May 22, 2009 04:44 PM|Nowman|LINK
That is really the only difference then? Also if you have the viewstate enabled on the page and you dont store anything in the viewstate would it really run any different then having the viewstate disabled?
May 22, 2009 04:51 PM|XIII|LINK
take a look at this example:
Control state vs viewstate.
May 28, 2009 12:14 PM|XFocus|LINK
So I'm assuming that if we're writing controls that aren't going to be distributed and we don't foresee turning off ViewState, then we should just use ViewState for all our needs? I'm hoping that's the answer because that's what I've been doing :-D
May 28, 2009 04:35 PM|XIII|LINK
only put those things in control state that your control always need when having the need to persist something. If you know that persistance is a nice feature but that a developer can do without use viewstate. So yes most of the time you'll be using viewstate.