解决方法
您只能从函数返回一个值,因此您不能从一个操作方法返回多个部分。
如果您尝试将两个模型返回到一个视图,请创建一个视图模型,其中包含要发送的两个模型,并将视图模型作为新的viewmodel。
例如。
如果您尝试将两个模型返回到一个视图,请创建一个视图模型,其中包含要发送的两个模型,并将视图模型作为新的viewmodel。
例如。
您的视图模型将如下所示:
public class ChartAndListviewmodel { public List<ChartItem> ChartItems {get; set;}; public List<ListItem> ListItems {get; set;}; }
那么你的控制器操作将是:
public ActionResult ChartList() { var model = new ChartAndListviewmodel(); model.ChartItems = _db.getChartItems(); model.ListItems = _db.getListItems(); return View(model); }
最后你的看法是:
@model Application.viewmodels.ChartAndListviewmodel <h2>Blah</h2> @Html.RenderPartial("ChartPartialName",model.ChartItems); @Html.RenderPartial("ListPartialName",model.ListItems);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。