Asp.net mvc 如何使用日期时间选择器作为editortemplate
如何在mvc视图中使用日期时间选择器Asp.net mvc 如何使用日期时间选择器作为editortemplate,asp.net-mvc,asp.net-mvc-4,jquery-ui,mvc-editor-templates,Asp.net Mvc,Asp.net Mvc 4,Jquery Ui,Mvc Editor Templates,如何在mvc视图中使用日期时间选择器 Here the date field is coming in the format specified in the Datetime editor template. But the calendor image is not coming. EditorTemplate:Datetime.cshtml @model DateTime? @Html.TextBox("", Model.HasValue ? Model.Value.ToString("
Here the date field is coming in the format specified in the Datetime editor template. But the calendor image is not coming.
EditorTemplate:Datetime.cshtml
@model DateTime?
@Html.TextBox("", Model.HasValue ? Model.Value.ToString("dd/MM/yyyy"):"", new { @class = "datefield" })
Model :
[Required]
public DateTime DateOfBirth { get; set; }.
Also jquery.ui.all.css is under my solution content>themes>base
Here the date field is coming in the format specified in the Datetime editor template. But the calendor image is not coming.
下面是需要datepicker的局部视图
@model PersonalDetails`
Here the date field is coming in the format specified in the Datetime editor template. But the calendor image is not coming.
`
@LabelFor(model=>model.DateOfBirth)
@Html.EditorFor(model=>model.DateOfBirth,new{@placeholder=“DateOfBirth”、@class=“datefield”、@type=“text”})@Html.ValidationMessageFor(model=>model.DateOfBirth)
Here the date field is coming in the format specified in the Datetime editor template. But the calendor image is not coming.
假设您已经为jQuery datepicker设置了编辑器:
Here the date field is coming in the format specified in the Datetime editor template. But the calendor image is not coming.
@Html.EditorFor(model => model.DateOfBirth, new { @placeholder = "Date Of Birth", @class = "datefield", @type="text" })
通过浏览器调试检查JS代码是否正常工作,日期选择器代码应如下所示:
Here the date field is coming in the format specified in the Datetime editor template. But the calendor image is not coming.
<script type="text/javascript">
$(document).ready(function () {
$(".datefield").datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: true,
showOtherMonths: true,
selectOtherMonths: true,
// other datepicker settings here as you want
});
});
</script>
为了简化这些脚本和样式声明,我建议您学习MVC样式/脚本绑定
Here the date field is coming in the format specified in the Datetime editor template. But the calendor image is not coming.
欢迎任何建议。使用示例代码有什么问题吗?您面临的问题是什么?bootstrap没有日期选择器。还有其他人编写了引导日期选择器@Shyju:我正在尝试实现jQueryUIDatePicker,我面临的问题是日历图像无法显示。
Here the date field is coming in the format specified in the Datetime editor template. But the calendor image is not coming.