作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想我知道答案,但是我想跳出一些想法。
我想将几个(在本例中为2个)略有不同的数据传递给一个View。我最初的想法只是将各种对象包装到一个包含对象中,然后按照这种方式传递它们。然后从“ View ”中,我会看到类似
var objContainer = ViewData.Model;
var thisObject = objContainer.ThisObject;
var thatObject = objContainer.ThatObject;
最佳答案
我发现创建附加的专用于 View 的类很有用。我将它们保留在名为“Core.Presentation”的单独命名空间中,以使事情井井有条。这是一个例子:
namespace Core.Presentation
{
public class SearchPresentation
{
public IList<StateProvince> StateProvinces { get; set; }
public IList<Country> Countries { get; set; }
public IList<Gender> Genders { get; set; }
public IList<AgeRange> AgeRanges { get; set; }
}
}
public partial class Search : ViewPage<SearchPresentation>
关于asp.net-mvc - 如何在ASP.NET MVC中将多个对象传递给“查看页面”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/238430/
我是一名优秀的程序员,十分优秀!