DataType(DataType.Date) format (MVC)

前端 未结 1 518
太阳男子
太阳男子 2021-01-14 00:53

Can we apply somehow the format for this?

[Display(Name = \"Date of Birthday\")]
[DataType(DataType.Date)]
public DateTime DOB { get; set; }
<
相关标签:
1条回答
  • 2021-01-14 01:11

    You can use the DisplayFormatAttribute

    Specifies how data fields are displayed and formatted by ASP.NET Dynamic Data.

    http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.displayformatattribute.aspx

    [DisplayFormat(DataFormatString = "{0:dd MMM yyyy}")]
    [Display(Name = "Date of Birthday")]
    [DataType(DataType.Date)]
    public DateTime DOB { get; set; }
    
    0 讨论(0)
提交回复
热议问题