2017-05-16 29 views
0

我有一個相當不尋常的問題。我有一個視圖結構,在以下格式的表格上重合:空td標籤無緣無故地出現

<table class="smartTable"> 
    @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 
    @Html.HiddenFor(model => model.Case_Status, new { @id = "caseStatus", @Value = "In Progress", @readonly = "true", htmlAttributes = new { @class = "form-control" } }) 
    <tr> 
     <td width="33.33%"> 
        <div class="form-group"> 
         @Html.LabelFor(model => model.Job_Name, htmlAttributes: new { @class = "control-label col-md-2" }) 
         <div class="col-md-10"> 
          @Html.EditorFor(model => model.Job_Name, new { htmlAttributes = new { @class = "form-control" } }) 
          <br /> 
          @Html.ValidationMessageFor(model => model.Job_Name, "", new { @class = "text-danger" }) 
         </div> 
        </div> 
     <td> 
     <td width="33.33%"> 
        <div class="form-group"> 
         @Html.LabelFor(model => model.Package_Name, htmlAttributes: new { @class = "control-label col-md-2" }) 
         <div class="col-md-10"> 
          @Html.EditorFor(model => model.Package_Name, new { htmlAttributes = new { @class = "form-control" } }) 
          <br /> 
          @Html.ValidationMessageFor(model => model.Package_Name, "", new { @class = "text-danger" }) 
         </div> 
        </div> 
     <td> 
     <td width="33.33%"> 
        <div class="form-group"> 
         @Html.LabelFor(model => model.Server_Name, htmlAttributes: new { @class = "control-label col-md-2" }) 
         <div class="dropdown"> 
          @Html.DropDownListFor(model => model.Server_Name, (IEnumerable<SelectListItem>)ViewBag.SrvNames, "Pick an option") 
          <br /> 
          @Html.ValidationMessageFor(model => model.Server_Name, "", new { @class = "text-danger" }) 
         </div> 
        </div> 
     </td> 
    </tr> 
</table> 

我有幾個這樣的表格(我不想改變格式)。問題是,當我的視圖加載時,在我已經放入代碼的三個<td>之間有空的<td>標籤。它只發生在兩個表和idk原因。

有人知道是什麼原因導致這種奇怪的行爲?

PS:以前的版本我的網站沒有這個問題。我沒有jQuery搞亂表結構。

回答

0

拿在你的上TD的就是看DIV 接近SelectListItem裏面像標籤這個

@ Html.DropDownListFor(型號=> model.Server_Name,(IEnumerable的)ViewBag.SrvNames, 「選擇一個選項」)
@ Html.ValidationMessageFor(型號=> model.Server_Name 「」 新{@class = 「TEXT-危險」})
+0

我真的不能明白你想說什麼。我看到的唯一區別是缺少和沒有
標籤。哪一個?如果我不能刪除它們,該怎麼辦? – GeorgiG

+0

你只需要結束SelectListItem標記

+0

但是SelectListItem不是一個標記,它被封裝在一個C#邏輯(@指向C#)。它是對某個C#類型進行強制轉換的一部分,並且不必遵守html結構。 – GeorgiG

相關問題