Asp.net mvc 4 如何将美元($)符号添加到@Html.TextBoxFor

Asp.net mvc 4 如何将美元($)符号添加到@Html.TextBoxFor,asp.net-mvc-4,Asp.net Mvc 4,如何将美元符号添加到mvc值 @Html.TextBoxFor(x => x.RefundAmount, new { @class = "form-control", id = "RefundAmount", name = "RefundAmount",disabled="disabled" }) 试试上面的代码 @Html.TextBoxFor(model => model.RefundAmount, new { @class = "required numeric", Valu

如何将美元符号添加到mvc值

@Html.TextBoxFor(x => x.RefundAmount, new { @class = "form-control", id = "RefundAmount", name = "RefundAmount",disabled="disabled" })
试试上面的代码

@Html.TextBoxFor(model => model.RefundAmount, new { @class = "required numeric", Value=String.Format("$ {0}",Model.RefundAmount) })
尝试此添加到视图: *在i标签之间放置$符号

<div class="input-icon">
    @Html.EditorFor(model => model.Sample,new {htmlAttributes = new { @class ="txt form control"} })
    <i>$</i>  ($ sign between the i tags)                   
</div>                 
@Html.ValidationMessageFor(model => model.Sample, "", new { @class = "text-danger" })

有关更多详细信息,请选中文本框中要在值之前添加$symbol?的位置。这取决于您尝试执行的操作。。如果您想要不应删除“$”的货币格式,请将其作为一个简单的解决方案放在textbox之外。如果只是要显示的文本,只需在文本框中显示的文本前面附加“$”即可。文章中的引用整洁CSS技巧不清楚。请解释清楚
<div class="input-icon">
    @Html.EditorFor(model => model.Sample,new {htmlAttributes = new { @class ="txt form control"} })
    <i>$</i>  ($ sign between the i tags)                   
</div>                 
@Html.ValidationMessageFor(model => model.Sample, "", new { @class = "text-danger" })
.input-icon {
    position: relative;
}

.input-icon > i {
    position: absolute;
    display: block;
    transform: translate(0, -50%);
    top: 50%;
    pointer-events: none;
    width: 35px;
    text-align: center;
    font-style: normal;
}

.input-icon > input {
    padding-left: 20px;
    padding-right: 0;
}