简体   繁体   English

如何在asp.net文本框中的左右添加标签

[英]how to add the label in both right and left in asp.net text box

I try to add label in the right side as well of the text box to include the unit of the value. 我尝试在文本框的右侧添加标签以包括值的单位。 I would like to have like this 我想要这样

and This code gives like this . 这段代码给出了这样的代码

this is my code 这是我的代码

    <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>

Thanks. 谢谢。

The class = "col-md-8" contains position:relative. class =“ col-md-8”包含position:relative。 Since this line has class="form control " and your GB doesn't have a class. 由于此行具有class =“ form control”,并且您的GB没有类。 It goes to its natural position. 它达到了自然的位置。 Adding a class should tell it where to go. 添加一个类应该告诉它去哪里。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM