Reputation: 1115
This is bizarre for me right now.. When I submit form to controller all input fields are mapped correctly, but this:
<input asp-for="Id" disabled class="form-control" value="something"/>
wont (always null).
when i remove disabled works perfectly!
I have another page with similar disabled input field and that page works fine. What happening here?
Upvotes: 1
Views: 4704
Reputation: 1
If your Input Field values coming from another page or database use "readonly".
Upvotes: 0
Reputation: 12695
The disabled attribute for element in HTML is used to specify that the input field is disabled. A disabled input is un-clickable and unusable. It is a boolean attribute. The disabled elements are not submitted in the form.
You could use readonly instead of disabled
<input asp-for="Id" readonly class="form-control" value="[something]" />
Reference : https://stackoverflow.com/a/1355734/10201850
Upvotes: 10
Reputation: 26
Are you trying to pass a default value if disabled? I'm not sure what are you trying to pass but try specifying the value attribute in your input, like:
<input asp-for="Id" disabled class="form-control" value="[something]" />
Upvotes: 0