我正在尝试将 DateTime 与 TextBoxFor 一起使用来显示 n 被编辑〜但我的模型的日期时间格式之一总是无法控制〜
看法
@Html.TextBoxFor(model => model.ClassDate,"{0:yyyy-MM-dd}", new { @readonly = "true",style = "width:135px",type="date"})
@Html.TextBoxFor(model => model.ClassDate,"{0:yyyy-MM-dd}", new { @readonly = "true",style = "width:135px"})
@Html.TextBoxFor(model => model.TeacherInfo.BDay,"{0:yyyy-MM-dd}", new { @readonly = "true",style = "width:135px",type="date"})
@Html.TextBoxFor(model => model.TeacherInfo.BDay,"{0:yyyy-MM-dd}", new { @readonly = "true",style = "width:135px"})
模型(我有两个表 n 使用外键)
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public Nullable<System.DateTime> BDay { get; set; }
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:MM-dd-yyyy}", ApplyFormatInEditMode = true)]
public Nullable<System.DateTime> ClassDate { get; set; }
结果 https://docs.google.com/file/d/0B53j6yH_R3ZeTjc2SmMxYS1OUkk/edit?usp=sharing