Search code examples
c#asp.netcontrolsviewstateweb-controls

where'd the webcontrol's viewstate go?


A TextBox is a WebControl which is a Control which has a ViewState property.

So why when I type '.' after myTextBox doesn't the ViewState property appear in the list of properties and methods?


Solution

  • It's for use with custom controls that need to keep a viewstate, not for external modification. It's protected (i.e. only accessible from derived objects) for a reason.

    For example, if you created a slider control that kept a viewstate for which position it was at, you would need to use the ViewState property. But there's no reason for anything else to use your slider control's viewstate.