How does asp.net MVC remember my incorrect values on postback?

后端 未结 3 1237
忘了有多久
忘了有多久 2021-01-05 15:27

This is working, but how???

I have a controller action for a post:

[AcceptVerbs(HttpVerbs.Post )]
public ActionResult Edit(Person person)
{
   bool i         


        
3条回答
  •  别那么骄傲
    2021-01-05 15:58

    The previously entered value is stored in the ModelState. When you have an error on the form, the helper pulls the value from the ModelState instead of using either values from the Model or the ones specifically supplied (under the hood, if you don't supply an explicit value it will default to the model value if there is one when there are no errors).

提交回复
热议问题