Retrieving the value of a asp:TextBox

后端 未结 2 1725
攒了一身酷
攒了一身酷 2021-01-19 21:49

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 chan

2条回答
  •  生来不讨喜
    2021-01-19 22:28

    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.

提交回复
热议问题