goal
Successfully apply the placeholder attribute for the @Html.Textbox method.
Problem
My application has the following syntax:
@Html.TextBox("term", new { placeholder = "What are you searching for?" })
But, when the TextBox displayed, the value input attribute is equal to placeholder = "What are you searching for?" . In other words, the placeholder attribute is not used as an attribute, but as an input value .
Knowledge
I have already searched this question on Google and Stack Overflow, but so far, without success.
This link has a solution with the same syntax that I use, but when I pass the second parameter to TextBox() , it appears as a value and nothing happens to the third parameter (in our case new { placeholder = "something" } ).
source share