mvc4同一视图传入两个模型

http://bbs.csdn.net/topics/390961335

用ViewModel,把内容和评论构造到一个类中

 

这个简单,定义一个模型,包含两个属性,各自为那两个模型的类型,用这个模型。
比如
class MyModel
{
    public TopicModel Topic { get; set; }
    public CommentModel Comment { get; set; }
}



ViewBag.A = 对象1;
ViewBag.B = 对象2;
return View();

posted @ 2015-10-10 14:36  _海阔天空  阅读(413)  评论(0编辑  收藏  举报