我在我的模型中使用DataType.Date属性,在我的视图中使用EditorFor.这在Internet Explorer 8和Internet Explorer 9中运行良好,但在谷歌浏览器中它显示日期选择器,而不是显示值,它只是在褪色的灰色文本中显示"月/日/年".
为什么Google Chrome不会显示价值?
模型:
[DataType(DataType.Date)]
public Nullable<System.DateTime> EstPurchaseDate { get; set; }
Run Code Online (Sandbox Code Playgroud)
视图:
<td class="fieldLabel">Est. Pur. Date</td>
<td class="field">@Html.EditorFor(m=>m.EstPurchaseDate)</td>
Run Code Online (Sandbox Code Playgroud)


如何在使用jQuery时阻止显示时间.datepicker()?以下是两个属性的模型部分(采用日期和到期日期)
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
[DisplayName("Expiration Date")]
public string ExpirationDate { get; set; }
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
[DisplayName("Date Taken")]
public string DateTaken { get; set; }
Run Code Online (Sandbox Code Playgroud)
使用@Html.EditorFor我正在处理的视图上的控件可以正常工作.但是,当我从中更改该控件时:
@Html.EditorFor(model => model.DateTaken)
Run Code Online (Sandbox Code Playgroud)
对此:
@Html.TextBoxFor(m => m.DateTaken, new { id = "dtkn" })
Run Code Online (Sandbox Code Playgroud)
为了使这个工作(标签哪个控件已datepicker应用于它):
<script>
$(function () {
$("#dtkn").datepicker('setDate');
$("#exp").datepicker('setDate');
});
$.datepicker.setDefaults({
buttonImageOnly: true,
buttonImage: '<%=Url.Content("~/Content/images/magnify.gif") %>',
defaultDate: -1,
gotoCurrent: true,
prevText: "<< Prev",
nextText: "Next >>"
});
</script>
Run Code Online (Sandbox Code Playgroud)
突然间,时间开始出现了.有什么建议?
编辑
我尝试过以下格式,但没有一种可以使用: …