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 entered text is still present in the textbox. I expect the textbox to be blank since EnableViewState is set to false. Am I missing something?
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- How to store image outside of the website's ro
- 'System.Threading.ThreadAbortException' in
- Request.PathInfo issues and XSS attacks
- How to dynamically load partial view Via jquery aj
相关文章
- asp.net HiddenField控件扩展问题
- asp.net HiddenField控件扩展问题
- Asp.Net网站无法写入错误日志,测试站点可以,正是站点不行
- asp.net mvc 重定向到vue hash字符串丢失
- FormsAuthenticationTicket expires too soon
- “Dynamic operations can only be performed in homog
- What is the best way to create a lock from a web a
- Add to htmlAttributes for custom ActionLink helper
Take a look at Server controls persist their state when EnableViewState is set to False
Example: Consider backcolor setting programmatically. On postback, if viewstate is switched off, the
background color
of the Textbox control is lost. However, the text value of the control is maintained.Note: If the backcolor was set directly in markup rather than in code behind, it would have persisted.
Following is from Understanding ASP.NET View State:
Also refer following
View State for TextBox and other controls that implement IPostBackDataHandler
How do I disable viewstate for a specific control?
Please check this Code Project article to better understand ViewState and Postback Data.
It is something like :
Below is related paragraph to your question.
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:
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