Time Input Field in ASP.NET MVC

前端 未结 4 1744
萌比男神i
萌比男神i 2020-12-21 08:29

I\'m having trouble trying to write a form with time field using ASP.NET MVC 4.

Model:

class Abcde {
    [DataType(DataType.Time)]
    public DateTim         


        
4条回答
  •  青春惊慌失措
    2020-12-21 09:17

    [Required]
    [DataType(DataType.Time)]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:HH:mm}")]
    public DateTime Time { get; set; }
    

    This code is correct. But it only works when you use EditorFor instead of TextBoxFor.

提交回复
热议问题