ASP.NET How ViewState works

后端 未结 3 1004
攒了一身酷
攒了一身酷 2020-12-06 19:57

I have a textbox and button on my .aspx page. The EnableViewState property of the textbox is set to false. But when I enter some text in the textbox and click the button the

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 20:15

    This is by design

    The following server controls persist their information across requests even when the control ViewState (the EnableViewState attribute) is set to False:

    * The TextBox control.
    * The CheckBox control.
    * The RadioButton control.
    

    This behavior occurs because the ViewState of a control is only one of the methods that are used to persist a control's attributes across requests. In the server controls that are mentioned in the "Symptoms" section, attributes that are not normally posted to the server through the form-get or the form-post are handled by the ViewState. These values include attributes of the control, such as BackColor. Attributes that are normally posted to the server are handled by the IPostBackDataHandler interface. An example of such an attribute is the checked attribute of the CheckBox control.

    Also read this article

    ASP.NET: TextBox and EnableViewState="False"

    For understanding of Viewstate I don't think there is a better article than MSDN

    Understanding ASP.NET View State

提交回复
热议问题