JqueryUI Datepicker无法运行ASP.NET MVC5

时间:2016-09-04 14:00:17

标签: asp.net jquery-ui asp.net-mvc-5 jquery-ui-datepicker

我安装了jqueryUI组合

cabal test

将它们捆绑在bundleconfig中,如下所示:

bundles.Add(new ScriptBundle("〜/ bundles / jqueryui")。包括(         "〜/脚本/ jQuery的UI- {版本} .js文件&#34));

    Install-Package jQuery.UI.Combined

我的观点:

    bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
      "~/Content/themes/base/jquery.ui.core.css",
      "~/Content/themes/base/jquery.ui.resizable.css",
      "~/Content/themes/base/jquery.ui.selectable.css",
      "~/Content/themes/base/jquery.ui.accordion.css",
      "~/Content/themes/base/jquery.ui.autocomplete.css",
      "~/Content/themes/base/jquery.ui.button.css",
      "~/Content/themes/base/jquery.ui.dialog.css",
      "~/Content/themes/base/jquery.ui.slider.css",
      "~/Content/themes/base/jquery.ui.tabs.css",
      "~/Content/themes/base/jquery.ui.datepicker.css",
      "~/Content/themes/base/jquery.ui.progressbar.css",
      "~/Content/themes/base/jquery.ui.theme.css"));

和scirpt:

<div class="input-group input-group-sm center-box">
                    <div class="text-font">Date of birth</div>
                    @Html.TextBoxFor(m => m.DateOfBirth, new { @class = "date-picker" })

And it looks like this

有什么想法吗?

2 个答案:

答案 0 :(得分:0)

  • 确保你正确添加了jquery css和js引用(更好的是你可以使用cdn link)
  • 尝试使用&#34; DateOfBirth&#34;提供该文本框ID像那样 @ Html.TextBoxFor(m =&gt; m.DateOfBirth,new {@ Id =&#34; DateOfBirth&#34;,class =&#34; date-picker&#34;})

答案 1 :(得分:0)

尽管为时已晚。可能会帮助正在寻找的人。

渲染 布局页面中的@ Styles.Render(“〜/ Content / themes / base / css”)。