现在我唯一想知道的是如何将图像绑定到剃刀视图中的"img src"。我已经搜索了其他问题,但没有找到循环图像的答案。目前写下来的方式行不通。~/图像/"是上传图像所在的文件夹。
@model List<propertyMgmt.Models.Property>
<div id="propertyList">
<label>Select properties to be Featured:</label><br />
<table class="table">
<tr>
<th>
@Html.Label("Property Description")
</th>
<th>
@Html.Label("Property Cost")
</th>
<th>
@Html.Label("Property Image")
</th>
<th>
@Html.Label("Featured??")
</th>
</tr>
@for (int i=0;i<Model.Count;i++)
{
<tr>
<td>
@Html.DisplayFor(m => m[i].PropertyDescription)
</td>
<td>
@Html.DisplayFor(m => m[i].PropertyCost)
</td>
<td>
<img src="~/Images/@(m=>m[i].PropertyImage)" />
</td>
<td>
@Html.CheckBoxFor(m => m[i].IsFeatured, new {
@onclick = "propertyCheckBoxSelect(this)" })
</td>
</tr>
}
</table>
</div>
你可以
这样使用。
<img src="~/Images/@(Model[i].PropertyImage)" />