jQuery dropdownlist MVC HTML attributes - maikelbos0/VDT GitHub Wiki
The jQuery-dropdownlist HTML helper extension supports supplying HTML attributes in the same two ways as normal HTML helper functions: by using a dictionary or an anonymous object.
@Html.JQueryDropdownlistFor(model => model.DemoProperty, new { id = "example-id", @class = "my-class" })
@Html.JQueryDropdownlistFor(model => model.DemoProperty, new Dictionary<string, object>() { { "id", "dictionary-id" }, { "class", "my-class" } })
This also allows you to define the data-multiselect and data-text-search attributes in your view instead of in your controller. Please note that it is not advised to change the data-field-name attribute; changing this will prevent the selected values to be automatically bound to your viewmodel on postback.
@Html.JQueryDropdownlistFor(model => model.DemoProperty2, new Dictionary<string, object>() {
{ "class", "dictionary-test-class" },
{ "id", "dictionary-test-id" },
{ "data-multiselect", "true" },
{ "data-text-search", "true" }
})