【发布时间】:2016-03-20 18:45:02
【问题描述】:
我有如下的详细视图页面
我想用 HTML 效果显示相关字段(如果有的话)
这是上面视图的示例 cshtml 代码
@for (int i = 0; i < Model.ListProductFields.Count; i++)
{
<div class="form-group">
@Html.LabelFor(x => x.ListProductLables[i].ProductFieldNameEn, Model.ListProductLables[i].ProductFieldNameEn, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.HiddenFor(m => m.ListProductFields[i].Field_ID)
@Html.TextAreaFor(m => m.ListProductFields[i].Field_Value_EN, new { @class = "form-control summernote", @row = 5 })
</div>
</div>
<div class="form-group">
@Html.LabelFor(x => x.ListProductLables[i].ProductFieldNameAr, Model.ListProductLables[i].ProductFieldNameAr, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.HiddenFor(m => m.ListProductFields[i].Field_ID)
@Html.TextAreaFor(m => m.ListProductFields[i].Field_Value_AR, new { @class = "form-control summernote", @row = 5 })
</div>
</div>
}
【问题讨论】:
-
LabelFor()方法中不需要第二个参数 - 可以只是@Html.LabelFor(x => x.ListProductLables[i].ProductFieldNameEn, new { @class = "control-label col-md-2" })但您显示的图像有一些textarea元素但代码 sn-p 不显示他们? -
非常抱歉,已编辑
-
此视图用于编辑吗?如果没有,那么你可以使用
@Html.Raw(m => m.ListProductFields[i].Field_Value_EN)(如果你想要视觉效果,可以放入一个带边框等的div) -
没有它的详细信息视图,因为我不知道仅使用它来应用富文本效果,我试试你的建议
-
@StephenMuecke 然后我收到以下错误
Cannot convert lambda expression to type 'string' because it is not a delegate type
标签: html asp.net asp.net-mvc asp.net-mvc-4 razor