开发者

MVC 3 - parse FormCollection to model

开发者 https://www.devze.com 2023-02-18 20:28 出处:网络
For my sample application I am building I am currently 开发者_JAVA技巧forced to pass a FormCollection object into my action method when attempting to do ajax updates on my view.

For my sample application I am building I am currently 开发者_JAVA技巧forced to pass a FormCollection object into my action method when attempting to do ajax updates on my view.

The reason I have chosen to pass FormCollection is that my view is rather complex and contains nested collections. If I were to Serialize and Json.Stringify it drops these nested collections when passed into my action method.

Is there a good technique to map my FormCollection object to an instance of my ViewModel once inside the controller ?

thanks


You can use TryUpdateModel<TypeOfYourModel>(YourModelInstance)

0

精彩评论

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