I have a simple strongly typed view, but I cant seem to update a textbox on my form after a post.
Here is my model:
public class Repair
{
public
From my dealings with the issue, I feel that this is by design bug in the framework. IMO:
@Html.TextBoxFor(x => x.Number)
should NOT be taking the value from ModelState
but rather directly from the model. At least this would be my expectation when I alter the model and return View(model)
.
ModelState.Clear()
is not an answer because it sanitizes ModelState
erasing ValidationSummary. Removing a key from ModelState
is neither good because it removes ValidationSummary for that key.
ModelState["Number"].Value =
new ValueProviderResult("New Value", "New Value", CultureInfo.CurrentCulture)
is correct but just too arcane. Thus, in such cases, my preference would be to use:
instead of
@Html.TextBoxFor(x => x.Number)