有没有办法将多个数据角色放入剃刀代码?我需要它来为jquery标记器标记我的选择列表。
我需要做以下事情:
@Html.DropDownList("Orientations", (SelectList)ViewBag.Orientations, "None", new { @multiple data-role="tagsinput", @class = "form-control" })
来自:
@Html.DropDownList("Orientations", (SelectList)ViewBag.Orientations, "None", new { @class = "form-control" })
但是这样做不起作用。
谢谢!
答案 0 :(得分:2)
您需要将data-role
中的连字符更改为下划线(html将使用连字符进行渲染)。
@Html.DropDownList("Orientations", (SelectList)ViewBag.Orientations, "None", new { multiple="multiple", data_role="tagsinput", @class = "form-control" })
或者你可以使用
@Html.ListBox("Orientations", (SelectList)ViewBag.Orientations, "None", new { data_role="tagsinput", @class = "form-control" })
@Html.ListBox
为您呈现属性multiple="multiple"