Reputation: 649
Given this .cshtml excerpt:
<div class="controls controls-row">
@Html.TextBoxFor(x => x.CountryName, new { placeholder = "Country", @class = "input-large", customerui = "Country" })
@Html.DisplayTextFor(x => x.CountryFootnote)
</div>
When changes for this page and this textbox are saved the Server updates both 'CountryName' and 'CountryFootnote' correctly. The 'Model.CountryName' and 'Model.CountryFootnote' in the results pane after each save are spot-on correct.
However, the result also contains the previous text input which remains shown in the textbox? See image below.
The [SAVE] button is coded as follows:
Upvotes: 0
Views: 409
Reputation: 649
Must update the Model's 'ActionResult Edit(CustomerModel Model)' to include this call ModelState.Remove("CountryName").
See how-to-update-the-textbox-value Answer 1.
[HttpPost]
public ActionResult Edit(CustomerModel model)
{
if (ModelState.IsValid)
{
...
...
// must do this so that the 'TexBoxFor()' uses the updated Model.CountryName and not the text entered
ModelState.Remove("CountryName");
}
return PartialView("CustomerEditControl", model);
}
Upvotes: 1
Reputation: 4010
Seems that the browser displayed the cached html to you.
Using Ctrl+F5 to reload all the resources in the page should fix your problem.
Upvotes: 0