How to Enter Placeholder Text Within Html.TextBoxFor in C# / MVC 4

Use an overload of TextBoxFor() with an htmlAttributes argument. This argument should be an anonymous object with all attributes you wish to assign to the input.

For example, if you want to set the placeholder and class attributes:

@Html.TextBoxFor( m => m.Email, new { placeholder = "Email", @class = "form-input" } )

Leave a Comment

tech