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!! :)
If this post is answer of your question then don't forgot to Click Mark As Answer
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.
Grz, Kris.
Read my blog | Twitter Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
Marked as answer by Nowman on May 23, 2009 05:31 PM
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?
If this post is answer of your question then don't forgot to Click Mark As Answer
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
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.
Grz, Kris.
Read my blog | Twitter Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
Nowman
Member
370 Points
135 Posts
Control State vs View State
May 22, 2009 08:08 PM|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!! :)
XIII
All-Star
182789 Points
23485 Posts
ASPInsiders
Moderator
MVP
Re: Control State vs View State
May 22, 2009 08:32 PM|LINK
Hi,
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.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
Nowman
Member
370 Points
135 Posts
Re: Control State vs View State
May 22, 2009 08:44 PM|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?
XIII
All-Star
182789 Points
23485 Posts
ASPInsiders
Moderator
MVP
Re: Control State vs View State
May 22, 2009 08:51 PM|LINK
Hi,
take a look at this example: Control state vs viewstate.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!
XFocus
Member
36 Points
10 Posts
Re: Control State vs View State
May 28, 2009 04:14 PM|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
XIII
All-Star
182789 Points
23485 Posts
ASPInsiders
Moderator
MVP
Re: Control State vs View State
May 28, 2009 08:35 PM|LINK
Hi,
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.
Grz, Kris.
Interested in Azure, ASP.NET (MVC), jQuery, WCF, EF, MS SQL, ...
Keep the forums clean: report to the moderation team!