From my relationship with the problem, I feel that this is a design error within the framework. IMO:
@Html.TextBoxFor(x => x.Number)
You should NOT take a value from ModelState , but rather directly from the model. At least it will be my expectation when I change the model and return View(model) .
ModelState.Clear()
is not an answer because it ModelState erasing ValidationSummary. Removing a key from ModelState not good because it removes the ValidationSummary for this key.
ModelState["Number"].Value = new ValueProviderResult("New Value", "New Value", CultureInfo.CurrentCulture)
is correct but too secret. Thus, in such cases, I prefer to use:
<input type="text" name="Number" id="Number" value="@Model.Number"/>
instead
@Html.TextBoxFor(x => x.Number)
source share