I have a properly working ajax form in an MVC3 application, with one exception. After I submit the form and get the result, even though the past in the model has a different input value (the sum in the example below), the old value is still displayed on the screen. I associate this with storing the value in the DOM and overriding / preventing a new value from the model. There are various ways to fix this by running the javascript function in one of the form events.
I would like to receive feedback on how best to deal with this situation, preferably native to MVC and without javascript. Here are the code snippets:
Parent view:
<div id="MyContainder"> @Html.Partial("MyPartialView", ClassContainingAmountProperty) </div>
Partial view:
@using (Ajax.BeginForm(actionName: "myaction", ajaxOptions: new AjaxOptions() UpdateTargetId = "MyContainder"}) @Html.EditorFor(x => x.Amount) <input type="submit" value="Save" /> )
controller
myModel.Amount = SomeNewNumber; return PartialView(myModel);
Alex
source share