将多个数据角色放入razor DropDownList
本文关键字:razor DropDownList 角色 数据 | 更新日期: 2023-09-27 18:26:36
有没有办法将多个数据角色放入剃刀代码中?我需要它来为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" })
但这样做是行不通的
非常感谢。
您需要将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"