Reputation: 51
I'm trying to add an specific attribute (data-toggle="select") to my DropDownListFor.
When I use:
@Html.DropDownListFor(model, myList, "Select..", new { @class = "form-control", @data-toggle="select" }).
I get the error saying that "Cannot resolve symbol 'data'" and "Cannot resolve symbol 'toggle'"
What can I do so my DropDownListFor recognizes the attribute data-toggle?
Ps: When I use
@Html.DropDownListFor(model, myList, "Select..", new { @class = "form-control"})
it works just fine
Upvotes: 0
Views: 479
Reputation: 46
The answer is actually pretty simple, just replace your -(dash) with a _(underscore) and you will be set.
@Html.DropDownListFor(model, myList, "Select..", new { @class = "form-control", @data_toggle="select" }).
Upvotes: 3