顶级页面视图名为“Create.cshtml”
在该页面上,我需要放置多个 _partialViews.cshtml 我使用剃须刀页面制作的:
<div>
<row>
<div class="col-md-6">
@await Html.PartialAsync("~/Views/Shared/_PartialDelegates")
</div>
<div class="col-md-6">
@await Html.PartialAsync("~/Views/Shared/_PartialApps")
</div>
</row>
</div>
现在的问题是我正在尝试使用 _PartialDelegates.cs 调用 _PartialDelegates.cshtml
_PartialDelegates.cshtml
@page
@model IMP.ECR.WEB.Views.Shared._PartialDelegatesModel
@{
}
<partial name="_PartialDelegatesView" model="Model.Avengers" />
哪个调用_PartialDelegates.cshtml.cs
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace IMP.ECR.WEB.Views.Shared
{
public class _PartialDelegatesModel : PageModel
{
public List<string> Avengers = new List<string>();
public void OnGet()
{
Avengers.AddRange(new[] { "Spiderman", "Iron Man", "Dr. Stange", "The Hulk" });
}
}
}
}
然后在 _PartialDelegatesView.cshtml 我有以下内容:
@model List<string>
<div class="col-md-12">
<h2>Avengers</h2>
<table class="table table-boardered table-striped" style="width:100%">
@foreach (var item in Model)
{
<tr>
<td>@item</td>
</tr>
}
</table>
</div>
慕的地6264312
呼如林
米琪卡哇伊
相关分类