這是另一個問題的分支。我將一個列表傳遞給作爲主視圖一部分的部分視圖。然而,當我查看網頁,我看到:現在作爲字符串的HTML呈現模型
System.Collections.Generic.List`1[...Models.OutcomeArea] List
,列表被正確渲染,但我不知道爲什麼上面的線是在HTML顯示。
Index.cshtml:
@using (Html.BeginForm("Index", "Search", FormMethod.Get, new { @class = "form-inline" }))
{
@Html.Action("_Checklist")
}
_Checklist.cshtml:
@Model List<....Models.OutcomeArea>
<div class="row">
<div class="col-md-4">
<h4 class="text-center">Outcomes</h4>
<p>
@foreach (var list in Model)
{
<input type="checkbox" id="@list.ID" name="@list.ID" /> @list.Category <br />
}
</p>
</div>
</div>
SearchController:
public PartialViewResult _Checklist()
{
var outcomeAreas = db.OutcomeArea.Where(oa => oa.Category != "").GroupBy(oa => oa.Category).Select(oa => oa.FirstOrDefault());
return PartialView("_Checklist", outcomeAreas.ToList());
}
在HTML中它顯示它的位置?什麼是渲染輸出? – David
字符串的第一部分看起來像來自List <.... Models.OutcomeArea>對象的標準'ToString()'。 –