What controls are supported by ViewState?

I am trying to wrap my head around a management infrastructure to understand which ASP.NET supports view state.

The following regular HTML controls exist: <input type="radio" checked="checked"/> β†’ I understand that they do not have a viewstate

Then there are HTML controls with runat = "server" <input type="radio" checked="checked" runat="server"/> β†’ Is viewstate supported between postbacks?

Then there are ASP.NET controls <asp:TextBox id="txtMyText" runat="server"/> β†’ I understand that they have a viewstate

We have several custom controls that inherit HtmlTextBox <myPrefix:myTextBox id="txtMyText" runat="server"/> β†’ Is this the same as type 2 above?

Is it possible to assume that any control with the tag runat="server" will have a supported viewport?

+4
source share
4 answers

There are 3 types of controls, standard HTML elements, such as HTML server controls that have the runat = server tag added and a full web control. Only web controls support viewstate.

+6
source

When we had problems with viewstate, I started using Viewstate support software from Binary Fortress http://www.binaryfortress.com/aspnet-viewstate-helper/

This gives you a real idea of ​​what is happening - as well as helping with the performance issues associated with the presentation in the view, you can decode the viewport with one click and see what is actually there, so you can understand which controls use viewstate and which are not, and exactly what they store there.

Also, something that no one has mentioned yet is ControlState. This happened together with ASP.NET 2, and the theory is that the important component necessary for the management function to function is in the control state, as well as data, etc. In the view, therefore, you can turn off the viewstate and bind the data to your control over each postback and control still basically work using controlstate. I say β€œtheory” because in practice, the implementation seems heterogeneous. If you look at the dropdownlist code using a reflector, for example, this is incorrectly implemented. Perhaps this has changed with later versions of the framework, I'm not sure. There is a lot of information about controlstate there, if you are looking for it, I just thought that I mentioned it.

+3
source

afaik no, that HTML controls are not designed to support anything in the view, if you need it, take webcontrols.

+2
source

Everything that you put in your pageview and add runat = "server" will have a supported view.

For dynamically added controls, it depends on when and how you add the control to the control tree. Check out the accepted answer to this question , but also check out my question here .

+1
source

All Articles