所以我已经使用我的项目实现了Chosen并且在多选中工作得很好,但是我希望为简单的下拉列表添加它。我在下拉列表中总共有80个条目,因此需要选择的搜索功能。这是我的代码。
<div class="editor-label">
<span style="color: red;">*</span> <strong>Select Therapist:</strong>
</div>
<div class="editor-field">
@Html.DropDownList("TherapistList", Model.TherapistList
, new
{
@class = "chzn-select",
data_placeholder = "Choose Therapist",
}
)
</div>
和
<script >
$(".chzn-select").chosen({
allow_single_deselect: false,
search_contains: false,
no_results_text: "Oops, nothing found!"
});
</script>
我在顶部添加了CSS和.JS参考。当我添加@Html.ListBox("TherapistList", Model.TherapistList
但我想在网站上显示带搜索选项的单选。
提前感谢。
答案 0 :(得分:1)
如果你没有调用@ Html.Listbox而是@Html.DropDown,你将会选择一个选择。
@Html.DropDownList("TherapistList", Model.TherapistList, new {
@class = "chzn-select",
data_placeholder = "Choose Therapist",
}
)