PDA

View Full Version : [CLOSED] Change Icon based on model value



AmitM
Oct 19, 2013, 5:25 AM
I have a property in my model called IsLocked, and I was wondering how would I change the icon on a TextFieldFor control?



Html.X().TextFieldFor(m => m.FirstName, false)
.Icon(Icon.Lock)
.ReadOnly(Model.IsLocked)
.FieldLabel("First Name"),


I would only want to show the Lock icon when Model.IsLocked == true.

Thanks,
Amit

Baidaly
Oct 19, 2013, 9:22 AM
Hello!

Try the following:


Html.X().TextFieldFor(m => m.FirstName, false)
.Icon(Model.IsLocked ? Icon.Lock : Icon.None)
.ReadOnly(Model.IsLocked)
.FieldLabel("First Name"),

AmitM
Oct 21, 2013, 2:54 PM
Icon.None ... that's great!