Search code examples
asp.netcontrolsviewstate

Controls that don't have ViewState


I am very new to Asp.Net.

Almost all the controls i have seen till now has ViewState.

So, my question is Are there any controls that don't have ViewState ? What are they.

I have googled, but din't find the correct solution.

Thank you !!


Solution

  • Every control has ViewState because that is where all attribute values are stored.

    To avoid ViewState you can disable it on the control (EnableViewState=false) and make sure when you set any properties (like Text, Visible etc.) you do that yourself on every postback (so that ViewState is not needed) - so in events like Page_Load instead of Button_Click.