如何在mvc 5中键入文本框时设置日期格式 [英] how to set the date format while typing in textbox in mvc 5
问题描述
大家好,
这里我在文本框中设置了一个字段名称startdate但是日期格式需要(MM:DD:YYYY)现在我想要改变(DD:MM:YYYY)。可以帮助完成这项任务。
in modal:
[DataType(DataType.Date)] [DisplayFormat(DataFormatString ={0:yyyy-MM-dd},ApplyFormatInEditMode = true)] public Nullable< system.datetime> Start_date {get;组; }
IN VIews: -
@ Html.TextBoxFor(m => m.Start_date, {0:dd / MM / yyyy})
hi to all,
here i'm set a field name startdate in textbox but the date format will takes(MM:DD:YYYY) now i want to change (DD:MM:YYYY).can anybody help for this task.
in modal:
[DataType(DataType.Date)] [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)] public Nullable<system.datetime> Start_date { get; set; }
IN VIews:-
@Html.TextBoxFor(m => m.Start_date, "{0:dd/MM/yyyy}")
推荐答案
@Html.TextBoxFor(m => m.Start_date, new { Value = Model.Start_date.ToString("dd-MM-yyyy"), id = "MySuperCoolId"});
这篇关于如何在mvc 5中键入文本框时设置日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!