文本框是否使用viewstate值 [英] textbox use viewstate values or not

查看:73
本文介绍了文本框是否使用viewstate值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

禁用文本框的视图状态不会影响文本框值。无论你是否禁用了viewstate,该值都会在回发后保留。

所以我的问题是textbox是否使用viewstate?



更新

因为我已经收到一些答案,这可能意味着值维护,因为服务器将值填充回文本框,这就是值保留的原因。如果是这种情况,那么,为什么不保持的HTML文本框的值?

解决方案
文本框控制被启用,可见的,并且不是只读,它呈现的表格元素(或者<输入类型= 文本 > < TextArea> )。提交表单时,这些元素将其值发送回服务器。无论是否启用了视图状态,控件都会加载已发布的值。



如果控件未启用,则可见或只读,则该值不会发回服务器。在这种情况下,如果启用了视图状态,控件将仅记住其值。



如果禁用了视图状态, TextChanged 事件不会触发。


啊,



原因是因为在TextBoxes的情况下,值在每次回发时都会提交给服务器,并且可以在 Request.forms 集合中找到。



这意味着尽管视图状态被禁用用于文本框,但该值是从 Request.forms获取的收集并显示。



干杯,

C


是,它将使用视图状态,如果你禁用视图状态,它在回发后不会保留该值。



如果页面回发,则文本框数据将会丢失。



这是关于你的问题的好文章。请仔细阅读



< a href =http://www.c-sharpcorner.com/UploadFile/225740/what-is-view-state-and-how-it-works-in-Asp-Net53/> http:// www。 c-sharpcorner.com/UploadFile/225740/what-is-view-state-and-how-it-works-in-Asp-Net53/ [ ^ ]

Disabling viewstate of textbox does not effect the textbox value. The value will retain after post back no matter you disable viewstate or not.
so my question is textbox do use viewstate or not?

update
As I have recevied some answer which probably means that value maintain because server fill back the values to textbox thats why values retain. if this is the case then why not html textbox values maintained?

解决方案

When the TextBox control is enabled, visible, and not read-only, it renders a form element (either <input type="text" > or <textarea>). These elements will send their values back to the server when the form is submitted. The control loads that posted value, regardless of whether view-state is enabled.

If the control is not enabled, not visible, or read-only, then the value will not be posted back to the server. In this case, the control will only remember its value if view-state is enabled.

If view-state is disabled, the TextChanged event will not fire.


Ahmm,

The reason is because in case of TextBoxes, the values gets submitted to the server on every postback and are available in the Request.forms collection.

This means that despite of the viewstate being disabled for textboxes, the value is fetched from the Request.forms collection and displayed.

Cheers,
C


Yes ,it will use view state,If you Disable the View state ,it doesn't retain the value after post back.

If the page get post back ,the textbox data will be loss.

Here is the Good article about your Question .Kindly read this

http://www.c-sharpcorner.com/UploadFile/225740/what-is-view-state-and-how-it-works-in-Asp-Net53/[^]


这篇关于文本框是否使用viewstate值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆