检索ASP的值:文本框文本框、ASP

2023-09-04 00:59:19 作者:时间偷走了初心

我有我的编辑对使用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.

 
精彩推荐