2017-06-08 64 views
0

我嘗試在文本框的右側添加標籤以包含值的單位。 I would like to have like this如何在asp.net文本框的右側和左側添加標籤

This code gives like this

這是我的代碼

<div class="form-group "> 

        @Html.LabelFor(model => model.files, htmlAttributes: new { @class = "control-label col-md-3" }) 
        <div class="col-md-8"> 
         @{ Html.EnableClientValidation(false); } 

         @Html.EditorFor(model => model.files, new { htmlAttributes = new { @class = "form-control " } })<span>GB</span> 
         @{ Html.EnableClientValidation(true); } 
         @Html.ValidationMessageFor(model => model.files, "", new { @class = "text-danger" }) 

        </div> 
       </div> 

感謝。

+0

則可以通過這兩個控件在單獨的span標籤嘗試,即 @ Html.EditorFor(型號=> model.files,新{htmlAttributes = {新@class = 「表單控制」 }}) GB 希望它會工作沒有把握,只是讓我知道,如果它的作品 感謝 –

回答

1

class =「col-md-8」包含position:relative。 由於這行有class =「form control」,並且你的GB沒有類。它走向了自然的位置。添加一個類應該告訴它去哪裏。

@Html.EditorFor(model => model.files, new { htmlAttributes = new { @class = "form-control col-md-11" } })<span class="col-md-1">GB</span> 
在簡單
+0

太好了!它現在正在工作。非常感謝.. –