检索ASP的值:文本框 [英] Retrieving the value of a asp:TextBox

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

问题描述

我有我的编辑对使用JavaScript客户端的价值被禁用的文本框。当我试图找回在服务器端的价值并不反映所做在客户端的变化。如果我的文本框的enabled属性设置为true,我可以检索值,但是用户能够把重点和编辑文本框。

I have a disabled TextBox that I am editing the value of on the client side with JavaScript. When I try to retrieve the value on the server side it does not reflect the change made on the client side. If I set the TextBox's enabled attribute to true I can retrieve the value, but the user is able to put focus and edit the TextBox.

有没有一种理智的方式来保持用户从到TextBox给予重点和编辑?

Is there a sane way to keep the user from giving focus and editing to the TextBox?

推荐答案

浏览器不张贴回值在禁用输入控件,因为你已经发现。可能是解决这个的最简单方法是钩住表单提交,并重新启用的输入作为表单提交;用户将无法修改价值的机会,它应该得到张贴着请求的其余部分。

Browsers don't post values back in disabled input controls, as you've discovered. Probably the easiest way to work around this is to hook onto form submission, and re-enable the input as the form is being submitted; the user won't have a chance to edit the value, and it should get posted with the rest of the request.

这是另一种可能是注入一个隐藏的元素到窗体中;这既可以通过脚本来维持镜像显示值,或添加在末端,以类似的方式与上述

An alternative might be to inject a hidden element into the form; this could either be maintained by your script, mirroring the displayed value, or added at the end, in a similar fashion to the above.

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

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