【发布时间】:2022-02-08 22:08:37
【问题描述】:
我删除了日历小部件中的时间选择和字段中的开始日期,也没有时间。 但主要问题是,当您选择日期时,当前时间仍会插入该字段中。只需要显示日期,不需要时间。
cshtml
<div class="form-group">
@Html.LabelFor(model => model.DateTo, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DateTo, "{0:d}", new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DateTo, "", new { @class = "text-danger" })
</div>
js
$("#DateTo").datetimepicker({
timepicker: false,
pickTime: false,
closeOnDateSelect: true,
dateFormat: "yy/mm/dd"
});
型号
[Display(Name = "DateTo", ResourceType = typeof(Resources.Resource))]
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
[Required]
public DateTime DateTo { get; set; }
jQuery DateTimePicker 插件 v2.4.5 如果有简单的asp net替代小部件,请告知。
【问题讨论】:
标签: javascript c# asp.net time datetimepicker