I have an HTML code number on my page that takes an integer value. The code is as follows:
@Html.TextBox("Answer[" + i + "].Score", null, new { @class = "form-control", type = "number", value="0", id = "Answer[" + i + "]_Score" })
In my model, I set all properties Scoreto 0 by default , but it still did not display from 0 in the view. Then I used value="0"directly at the input, but it still does not display 0.
It displays:
<input class="form-control" id="Answer[0]_Score" name="Answer[0].Score" type="number" value="">
This is only a problem when I go to save the form, a null value is sent to the controller when the evaluation is not null, so the form is not submitted.
Is there a way to get this default value 0 instead of an empty value?
source
share