【发布时间】:2014-02-01 23:40:36
【问题描述】:
我需要一些关于如何使用 Razor 引擎在 MVC 5 项目上安装 Date Picker Bootstrap 3 的指南。我找到了这个链接here,但无法让它在 VS2013 中工作。
从上面后面链接中的示例复制我已经完成了以下操作:
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/bootstrap-datepicker.js", // ** NEW for Bootstrap Datepicker
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/bootstrap-datepicker.css", // ** NEW for Bootstrap Datepicker
"~/Content/site.css"));
然后我将脚本添加到索引视图中,如下所示
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
$('.datepicker').datepicker(); //Initialise any date pickers
</script>
}
现在,如何在这里调用日期选择器?
<div class="form-group input-group-sm">
@Html.LabelFor(model => model.DropOffDate)
@Html.TextBoxFor(model => model.DropOffDate, new { @class = "form-control", placeholder = "Enter Drop-off date here..." })
@Html.ValidationMessageFor(model => model.DropOffDate)
</div>
【问题讨论】:
-
请向我们展示您正在使用但不起作用的 cshtml/Razor 代码。谢谢
-
感谢您的回复。我已经相应地更新了我的帖子
-
我会启动 VS 看看能不能搞定!
-
您是使用 NuGet 添加文件还是手动添加?
-
waqar ahmed 是迄今为止最简单的解决方案。
标签: asp.net-mvc twitter-bootstrap razor