0

How can i add dollar symbol to the mvc value

@Html.TextBoxFor(x => x.RefundAmount, new { @class = "form-control", id = "RefundAmount", name = "RefundAmount",disabled="disabled" })
ArunRaju
  • 11
  • 1
  • 8
  • Where you want to add `$` symbol? – Siva Gopal Feb 16 '17 at 12:01
  • Before value in the text box – ArunRaju Feb 16 '17 at 12:02
  • It depends on what you are trying to do.. If you want currency formatting for which '$' should not be removed then put it outside of textbox as a simple solution. If it is just text you want to display you can simply append '$' in front of the text you display in textbox. – Siva Gopal Feb 16 '17 at 12:06
  • Refer neat CSS trick from [this SO](http://stackoverflow.com/questions/2913236/html-text-input-field-with-currency-symbol) – Siva Gopal Feb 16 '17 at 12:08

3 Answers3

1
@Html.TextBoxFor(model => model.RefundAmount, new { @class = "required numeric", Value=String.Format("$ {0}",Model.RefundAmount) })

Try this

Hassan Nazeer
  • 357
  • 3
  • 5
0
@Html.TextBoxFor(x => "$"+x.RefundAmount, new { @class = "form-control", id = "RefundAmount", name = "RefundAmount",disabled="disabled" })

Try this above code

r.vengadesh
  • 1,721
  • 3
  • 20
  • 36
0

Add to view : *put $ sign between i tags

<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" })

css:

.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;
}

for more details check link here

novog
  • 121
  • 11