2015-12-15 49 views
1

我有一個像下面的詳細視圖應用HTML效果在asp.net mvc的

enter image description here

我想表明與HTML效果是相關領域(如果有的話)

這個細節視圖頁面對於上述觀點

@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>    
    } 
+0

在你的'LabelFor()'方法中不需要第二個參數 - 可以只是'@ Html.LabelFor(x => x.ListProductLables [i] .ProductFieldNameEn,new {@class = 「control-label col-md-2」})'但你顯示的圖像有一些'textarea'元素,但代碼片段不顯示它們? –

+0

非常抱歉,編輯它 – kez

+0

這是編輯視圖嗎?如果不是,那麼你可以使用'@ Html.Raw(m => m.ListProductFields [i] .Field_Value_EN)'(並且放入帶有邊框的div中,如果這是你想要的視覺效果) –

回答

1

樣品CSHTML代碼如果您視圖創建不進行編輯,然後就可以用@Html.Raw()輸出非ENCO ded html。

@Html.Raw(Model.ListProductFields[i].Field_Value_EN) 

如果你也想邊界,填充等的視覺效果,那麼你可以把這個<div>元素和風格這裏面。

備註:A <label>是一個與窗體控件關聯的可訪問元素(點擊它將焦點設置到關聯的控件上,但在這種情況下您沒有)。考慮只使用<span>@Model.ListProductLables[i].ProductFieldNameEn<span>