Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding an icon to a textbox in mvc5

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.

like image 359
Damian Buttle Avatar asked Dec 29 '25 18:12

Damian Buttle


1 Answers

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. enter image description here

For more details on same look bootstrap documentation here.

like image 90
Ashish Shukla Avatar answered Dec 31 '25 19:12

Ashish Shukla



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!