I'm currently trying to add an icon to a text box in mvc5. I'm quite new to asp.net and I can't figure out how to do it. I would usually just use <i class="fa fa-icon"></i>.
Within the input area, however I have:
@Html.TextboxFor(m=> m.EmailAddress, new {@placeholder = "Email Address"})
Any help would be greatly appreciated.
If you are using bootstrap with ASP.Net MVC 5 (which is by default part of new MVC 5 application), then you can use bootstraps class to achieve that
<div class="form-group has-success has-feedback">
@Html.TextboxFor(m=> m.EmailAddress, new {@class="form-control" @placeholder = "Email Address"})
<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
</div>
This code will display success icon with text box. Below is snapshot.

For more details on same look bootstrap documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With