I have a controller action UpdateCustomer(CustomerDto customer)that returns PartialViewResultwith a model, which is also CustomerDto:
[HttpPost]
public PartialViewResult UpdateCustomer(CustomerDto customer)
{
CustomerDto updatedCustomer = _customerService.UpdateCustomer(customer);
updatedCustomer.Name = "NotThePostedName";
return PartialView("CustomerData", updatedCustomer);
}
In my opinion, I have the following line:
@Html.TextBoxFor(model => model.Name)
So far so good. In my opinion, I am making an asynchronous record for this action method, the model binding does its job, and I can update the client in the database. Then I want to provide the client with an updated client. For example, I would like to change the client name in my controller. However, what is obtained is always properties from published customer, not properties from updatedCustomer.
MVC3 , , . -, (?) MVC3, ViewData.ModelState ViewData.Model.
366-367 System.Web.Mvc.Html.InputExtensions:
string attemptedValue =
(string) htmlHelper.GetModelStateValue(fullName, typeof(string));
tagBuilder.MergeAttribute("value",
attemptedValue ?? ((useViewData)
? htmlHelper.EvalString(fullName)
: valueParameter), isExplicitValue);
, attemptedValue ModelState. CustomerDto.Name (, ).
, ? ? , , , , .