我似乎无法使用此代码。如何让TextBoxFor
显示在屏幕上?我没有尝试过任何工作。
@foreach (var items in Model.Pages[0].Items){
<div class="form-group">
<label for="pageType" class="col-sm-2 control-label">Label:</label>
<div class="col-sm-10">
@{
string htmlOutput;
if (items.PageItemTypeId == (int)HOD.Controllers.PageItemTypesEnum.MainTextContent)
{
htmlOutput = @Html.TextBoxFor(x => items.PageContent, new { @class = "form-control", @placeholder = "Content" }).ToHtmlString();
Response.Write(htmlOutput);
}
<input type="hidden" id="pageTypeId" />
</div>
</div>
答案 0 :(得分:13)
您应该创建Razor @if
statement:
<div class="col-sm-10">
@if (items.PageItemTypeId == (int)HOD.Controllers.PageItemTypesEnum.MainTextContent)
{
@Html.TextBoxFor(x => items.PageContent, new { @class = "form-control", @placeholder = "Content" });
}
<input type="hidden" id="pageTypeId" />
</div>