ASP.NET MVC 框架中的 MVVM 和 ModelBinder
我有一系列视图,每个视图都有自己的 ViewModel 类,其中包含它们显示自身所需的所有内容,例如:
public class CreateResourceViewModel
{
public Project Parent { get; set; }
public SelectList Categories { get; set; }
public Resource Resource { get; set; }
}
我想使用的后操作方法如下所示
[AcceptVerbs (HttpVerbs.Post)]
public ActionResult Create (Resource resource)
{
// Update code...
}
:我感兴趣的唯一对象是 CreateResourceViewModel 的 Resource 属性,而不是 CreateResourceViewModel 本身。其他一切都只是为用户服务,他们正在更新的是资源类...
这在 MVC 框架内可能吗(即使它是 v2 CTP)?
谢谢大家
I've got a series of views, each are typed to have their own ViewModel class which contains everything they need to display themselves, for example:
public class CreateResourceViewModel
{
public Project Parent { get; set; }
public SelectList Categories { get; set; }
public Resource Resource { get; set; }
}
The post action method for this I'd like to use would look like this:
[AcceptVerbs (HttpVerbs.Post)]
public ActionResult Create (Resource resource)
{
// Update code...
}
Notice that the only object I'm interested in is the Resource property of the CreateResourceViewModel, not the CreateResourceViewModel itself. Everything else is just gravy for for the user, what they're updating is the resource class...
Is this possible within the MVC Framework (even if it's v2 CTP)?
Thanks all
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然。使用:
Sure. Use: