我正在使用 Microsoft MVC 和 C#。我创建了一个用户控件(example.ascx),并在顶部继承System.Web.MVC.ViewUserControl<PostTransferViewModel>
现在,当我的模型名称附加到 ViewUserControl 时,我得到“当前上下文中不存在名称‘模型’”和“当前上下文中不存在名称‘Html’。如果我<PostTransferViewModel>
从末尾删除ViewUserControl 然后一切正常,但我需要<PostTransferViewModel>
.
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<PostTransferViewModel>" %>
<div class="postTransferTank">
<h2>
Approved Post Transfers</h2>
<% if (Model.ApprovedPostTransfers.Count() == 0)
{ %>
<span class="emptyList">There are currently no approved Post Transfers for this tank.</span><br />
<% } %>
<% else
{ %>
<%=Html.DisplayFor(x => x.ApprovedPostTransfers,"PostTransferList") %>
<% } %>
<br />
<%=Html.ActionLink<PostTransferController>(x => x.NewPostTransfer(), "Enter Post Transfer", new { @class = "create-link" })%>
<br />
<% if (Model.DraftPostTransfers.Count() != 0)
{ %>
<h2>
Draft Post Transfers</h2>
<%=Html.DisplayFor(x => x.DraftPostTransfers, "PostTransferList") %>
<% } %>
</div>