I am migrating my web application from ASP.NET MVC to ASP.NET Core 2.0. But I having problem on setting html attributes in the Tag Helpers for Select Tag. For example, in my old project I have the below html helper for drop-down list.
var cssClass = "select-arrow " + Model.ControlCss;
@Html.DropDownListFor(model => model.Value, options, "", new { @class = cssClass })
Here, I have used the bellow html attributes for the html helper class to add another CSS classes.
new { @class = cssClass }
Now my question is how do I set the html attributes in asp.net core? Does the blow code work? Please let me know the details.
<select asp-for="Value" asp-items="options" class="form-control, cssClass"></select>
You can insert a string using @PropertyName
:
<select asp-for="Value" asp-items="options" class="form-control select-arrow @Model.ControlCss" />