【发布时间】:2019-07-04 17:19:06
【问题描述】:
我的 DROPDOWNLIST 不可搜索,它是正常的下拉列表。您可以在图像上看到我对创建的看法。我使用了选择的插件。我将 css 和 js 文件添加到 _Layout。需要什么功能吗?
创建.cshtml
@model StockControl.Models.EntityFramework.IncomingProduct
@{
ViewBag.Title = "Create";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Add new product</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.materialId, "Material Name", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("materialId", null, htmlAttributes: new { @class = "form-control chosen" })
@Html.ValidationMessageFor(model => model.materialId, "", new { @class = "text-danger" })
</div>
</div>
}
@section scripts{
<script>
$(function () {
$(".chosen").chosen();
});
</script>
}
_Layout.cshtml
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>_Layout</title>
<link href="~/Content/chosen.min.css" rel="stylesheet" />
</head>
<body>
@Html.Partial("_Navbar")
<div class="container">
@RenderBody()
</div>
@RenderSection("scripts", false)
<script src="~/Scripts/chosen.jquery.min.js"></script>
</body>
</html>
提前致谢。
【问题讨论】:
标签: asp.net asp.net-mvc model-view-controller