如何在Drupal中添加像这样的搜索框到ASP MVC 5应用程序来搜索所有网站?我是ASP MVC的新手,在Drupal有经验。
答案 0 :(得分:0)
您必须为搜索选项添加以下代码:
首先,您需要添加以下JS文件的参考:
Download JS and CSS files for Select2 Dropdown List
<script src="~/Scripts/select2.full.min.js"></script>
<link href="~/Content/select2.min.css" rel="stylesheet" />
Download and include in your view
然后在您的视图中添加以下代码:
$(function () {
$("#SearchBoxddl").select2({
placeholder: "-Select Options-"
});
});
<div class="col-sm-4 ">
<strong class="text-primary"><i class="fa fa-search"></i> Select Options</strong>
<p class="form-static-control">
@Html.DropDownListFor(model => model.Id, new SelectList(Model.SelectList, "Id", "Name"), "-Select Options-", new { @class = "form-control", @id = "SelectBoxddl" })
</p>
</div>