我该如何在MVC5中放置日期选择器

0 c# asp.net-mvc jquery asp.net-mvc-5

我有以下代码:

<div class="form-group">
            @*@Html.LabelFor(model => model.DT_AGENDAMENTO, htmlAttributes: new { @class = "control-label col-md-2" })*@
            @Html.Label("Data de Agendamento", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10" id="datepicker">
                @Html.EditorFor(model => model.DT_AGENDAMENTO, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.DT_AGENDAMENTO, "", new { @class = "text-danger" })
            </div>
        </div>
Run Code Online (Sandbox Code Playgroud)

在我看来,我有:

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/jqueryui")

    $(document).ready(function(){
        $(".datepicker").datepicker();
    });
}
Run Code Online (Sandbox Code Playgroud)

如何在我的文本框(剃刀)上放置Datepicker(jQuery或其他)?在chrome开发工具上调试页面时,出现此错误:

GET http:// localhost:55839 / bundles / jquery-ui 404(未找到)

我不知道该怎么办。

Had*_*dee 5

对于最新的浏览器,最好的选择是将这些数据属性添加到类定义中的相关属性中:

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
Run Code Online (Sandbox Code Playgroud)

然后只需在属性中使用@ Html.EditorFor作为属性。

对于包错误,请在App_Start> BundleConfig.cs中检查bundles / jquery-ui 。可能定义有错误