【问题标题】:Date not displaying in EditorFor日期未在 EditorFor 中显示
【发布时间】:2020-02-15 09:28:38
【问题描述】:

我想在 editorfor 字段中显示数据库中的值,但它保持空白。该值存在于值字段中,但不显示在页面中。

如果我使用以下解决方案:

Display a formatted date in an EditorFor()

@Html.TextBoxFor(m => m.Van, new { @Value = model.Van.ToString("yyyy/MM/dd"), @class="datepicker" })

我得到了值,但没有得到 EditorFor 字段默认提供的日期选择器。

型号:

[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime Van{ get; set; }

查看:

@Html.EditorFor(model => model.Van, new { htmlAttributes = new { @class = "form-control" } })

【问题讨论】:

  • 你在使用 Jquery 日期选择器吗?

标签: html entity-framework asp.net-mvc-4


【解决方案1】:

在将格式更改为“yyyy/MM/dd”后,这是一个 Chrome 问题。

【讨论】:

    猜你喜欢
    • 2014-04-26
    • 2021-10-19
    • 2012-09-19
    • 1970-01-01
    • 1970-01-01
    • 2017-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多