Does anybody know how to specify class html attribute of password box in Razor?
Here is what I currently have but it throws errors:
@Html.PasswordFor(x => x.Password, new { id="pbPassword", class="loginPassword" })
Thanks
class
is a keyword to declare a new class in C#. So you must add @
in this case.
Try this:
@Html.PasswordFor(x => x.Password, new { id="pbPassword", @class="loginPassword" })
Class is a reserved word so you need to prepend it with an "@" to distinguish it from the reserved word, e.g.
@Html.PasswordFor(x => x.Password, new { id="pbPassword", @class="loginPassword" })
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