I can't seem to get this code to work. How do I get the TextBoxFor
to show on the screen? Nothing I try works.
@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>
You should create a 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With