View Binding for Controller does not work in "disabled" fields

Asked

Viewed 32 times

0

I use the property asp-for in the elements of my View to pass their values to the Controller at the time of post page.

<input id="txtExamNumber" asp-for="ExamNumber" class="form-control" />

What I realized is that if I turn off the field (disabled) through javascript, the Binding for the Controller no longer works. In fields hidden, for example, it works perfectly.

What is the explanation for this behavior? There are ways around?

1 answer

1

This is an expected behavior on the part of the HTML form, it does not send the disabled (disabled) fields, because in theory, who configured them like this does not need them on the server.

You can replace disabled by readonly. https://www.w3schools.com/tags/att_input_readonly.asp

Browser other questions tagged

You are not signed in. Login or sign up in order to post.