I use a strongly typed model for my presentation. I have a disabled text field whose value I am updating with javascript. The text box is displayed using this
<%: Html.TextBoxFor(model => model.TotalAmount, new { disabled = "disabled"})%>
This displays a text box with NAME and ID as "TotalAmount". TotalAmount is also a property of my model that binds to this view.
Javascript to update its value in the view, as it happens in its function:
document.getElementById('TotalAmount').value = {assigning new value here};
The function calls the call, and I can see the value in the disabled text field when I change the value in another editable text field. However, when I submit this form to my action method, as shown below:
[HttpPost] public ActionResult Process (ProcessVM FormPostVM) { }
the property of the disabled text field [TotalAmount] still has the old value, but the changed text field that I changed contains the new value entered. Why doesn't the disabled text box contain an updated javascript value?
I tried to use
ModelState.Remove("TotalAmount");
in the action method above, but, as I already thought, it does not work.
Any clues, clues?
Thank you for your time....
source share