How can i set the html id attribute in razor
16,379
Just add the id property to the html-attributes. That will override the default id generated by the editorfor-helper-methode.
Look at this post: How can I set id using Html.EditorFor with MVC3
@Html.EditorFor(model => model.News_Date, new { htmlAttributes = new { @class = "form-control", id = "my_custom_id" }})
Author by
Mustafa Sattar
Updated on June 09, 2022Comments
-
Mustafa Sattar almost 2 years
I want to configure datepicker in my MVC 5 form. I have included all the reference libraries like Jquery, datepicker etc.
Following is the line from MVC razor view, which is created by Visual Studio in a result for MVC 5 scaffolding.
@Html.EditorFor(model => model.News_Date, new { htmlAttributes = new { @class = "form-control" }})
any help in this regard