我正在尝试使用基本的JQuery DatePicker(日历)和时间控制。它在Chrome中完美运行,但在IE中它只给我文本框。
查看:
<div class="form-group">
@Html.LabelFor(model => model.STARTDATE, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.STARTDATE, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.STARTDATE, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.STARTTIME, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.STARTTIME, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.STARTTIME, "", new { @class = "text-danger" })
</div>
</div>
MODEL:
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}",ApplyFormatInEditMode = true)]
[Display(Name = "Date")]
public DateTime? STARTDATE { get; set; }
[DataType(DataType.Time)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:H:mm}")]
[Display(Name = "Time")]
public DateTime? STARTTIME { get; set; }
答案 0 :(得分:0)
似乎你既不使用JqueryUI也不使用其他插件。所以我假设你看到的DatePicker只是Chrome默认为日期输入呈现的那个。
正如您所看到的here,它仅受Chrome,Opera和iOS Safari的支持。 出于这个原因,我建议你使用像jQuery UI这样的插件来显示日期选择器。
asp.net documentation中有一个完整示例,展示了如何将其集成到MVC5中。