2017-06-08 63 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

太好了!它现在正在工作。非常感谢.. –