I have created a user interface using basic HTML attributes and the Bootstrap framework.
I am now looking to integrate Html.EditorFor()
in place of
<input type="text" class="form-control" />
.
This is how I attempted to add it:
<%= Html.EditorFor(model => model.Name,new { @class = "form-control" }) %>
However, when I view my HTML page, it does not display as expected. Instead, it shows a standard HTML input field without the Bootstrap styling applied. Interestingly, the class attribute works well with Hrml.TextBoxFor()
.
I am using the ASPX C# View Engine rather than Razor.
After researching on Stack Overflow, it seems that my syntax is correct according to most answers.
How can I apply CSS classes to Html.EditorFor()
successfully?