TextBoxFor value not updating after post

后端 未结 5 793
暗喜
暗喜 2021-02-05 11:00

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          


        
5条回答
  •  不要未来只要你来
    2021-02-05 11:30

    When you post a model back to an ActionResult and return the same View, the values for the model objects are contained in the ModelState. The ModelState is what contains information about valid/invalid fields as well as the actual POSTed values. If you want to update a model value, you can do one of two things:

    ModelState.Clear()

    or

    ModelState["Number"].Value = new ValueProviderResult("New Value", "New Value", CultureInfo.CurrentCulture)

提交回复
热议问题