开发者

do you have to qualify control property names when using the default asp.net mvc model binder

开发者 https://www.devze.com 2022-12-14 04:38 出处:网络
let say your controller action looks like this: public ActionResult Update(Car myCar) { } if you have a textbox that has

let say your controller action looks like this:

public ActionResult Update(Car myCar)
{
}

if you have a textbox that has

 <input type='text' name='year' value='1990'>

it seems like it will bind to the myCar.year field just fine

but if you have nested objects or complex lists, etc开发者_开发技巧, it seems like you have to qualify the names of controls like:

 <input type='text' name='myCar.year' value='1990'>

Even though the above is just a simple field, i thought it gets the point across.

the question is, when do you have to "qualify" the input names and when do you not ?


To quote someone who seems to know ... ;)

"if you have nested objects or complex lists, etc, it seems like you have to qualify the names of controls"

You hit the nail on the head, sir!

Kindness,

Dan

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号