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" } )
Try to the following
This code is tested and it's working
@Html.TextBox("CustomarName" ,null, new { @class = "form-control" , @placeholder = "Search With Customar Name" })
Hope it helps to you
This works for me...
@Html.TextBoxFor(m => m.Username, new { @placeholder = "Username", @class = "input100" })