When EnableViewstate = false and I do postback, my textbox control retains the text value but label control does not. I am changing the text for both label and textbox on a button’s click event.
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = "Message Changed";
Label1.Text = "Message Changed";
}
There is another button my page for just postback.
Also if I do no need viewstate for this control, then is there a list of all the controls that don’t need the viewstate?
All controls which implement
IPostBackDataHandlerload their values even if ViewState is off. Note that events likeTextChangedand other properties likeForeColordon’t work when ViewState is disabled.Here’s a list of controls which implement
IPostBackDataHandlerWhy textbox persists data during postback even if View State set to off