Reputation: 13
I want to add a class and a type on my Html.EditorFor, so I proceed like this :
Html.EditorFor(model_ => Model.MinDate, new { @class = "datepicker uk-input uk-form-small", type="date"})`
but still doesn't work.
This is the code in Chrome when I inspect :
<input class="textbox valid" data-val="False" data-val-date="The field MinDate must be a date." id="MinDate" name="MinDate" type="text" value="2018-01-19" aria-invalid="false">
And after research, I don't know why the class doesn't appaer. Can you explain me ? (sorry for my bad english)
Upvotes: 0
Views: 48
Reputation: 13
I found the solution. I use "TextBoxFor" and not "EditorFor" and it works !
Html.EditorFor(model_ => Model.MinDate, new { @class = "datepicker uk-input uk-form-small", type="date"})`
Upvotes: 0
Reputation: 6866
You should be able to achieve this as:
@Html.EditorFor(model_ => Model.MinDate, new { htmlAttributes = new { @class = "datepicker uk-input uk-form-small" } })
Upvotes: 1