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

后端 未结 3 1273
忘了有多久
忘了有多久 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 16:18

    ModelState holds KeyValuePairs for every form element with the key being the field name and the value is what you put in the field. Then the Html Helpers look in ModelState and if you don't explicitly specify a value, they will pull the value from ModelState.

提交回复
热议问题