I have a general question about some Razor Syntax I keep finding in a project I am working on...
One of the main helpers being used is: @Html.InputFor
They then insert some Lambda for example: @Html.InputFor(_ => _.User)
My question is, how do I work with this helper (I couldn't find any details via a google search) i.e adding attributes like custom css classes?
Is there a better helper I should be using? (I am new to Razor)
I think you mean @Html.TextBoxFor
. That extension method can be found in the InputExtensions
class.
How to attach an attribute to it? Use the htmlAttributes
property:
@Html.TextBoxFor(x => x.User, htmlAttributes : new { @class = "cssclass" } )
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