Asp.net mvc 3 是';中断';MVC是否在视图中包含有关模型的信息?
我是MVC新手,我对自己的观点有疑问 我有一个强类型视图:Asp.net mvc 3 是';中断';MVC是否在视图中包含有关模型的信息?,asp.net-mvc-3,Asp.net Mvc 3,我是MVC新手,我对自己的观点有疑问 我有一个强类型视图: @model CellularAutomata.Models.D1CellularAutomata @{ ViewBag.Title = "View"; } <h2>View</h2> <table> @foreach (CellularAutomata.Models.Grid grid in Model.GridHistory){ <tr> @fore
@model CellularAutomata.Models.D1CellularAutomata
@{
ViewBag.Title = "View";
}
<h2>View</h2>
<table>
@foreach (CellularAutomata.Models.Grid grid in Model.GridHistory){
<tr>
@foreach (CellularAutomata.Models.Cell cell in grid.Cells[0]){
if (cell.State == CellularAutomata.Models.State.On){
<td>X</td>
}
if (cell.State == CellularAutomata.Models.State.Off){
<td>O</td>
}
}
</tr>
}
</table>
或
如果这是错误的,那么最好的解决方法是什么?一点也不,因为您的视图是针对您的模型的强类型视图。如果您的视图是模型不可知的,那么这将是一个问题,但由于这是D1CellularAutomata的视图,因此在视图中具有D1CellularAutomata特定的引用是合适的
(CellularAutomata.Models.Cell cell in grid.Cells[0])
(cell.State == CellularAutomata.Models.State.On)