asp.net mvc - Remove Time From DateTime Property in @Html.EditorFor -
i want remove time datetime property in razor
@html.editorfor(model => model.date_of_birth)
i tried model.date_of_birth.date
,model.date_of_birth.date.toshortdatestring()
but showing errors.
you decorate view model property [displayformat]
attribute:
[displayformat(applyformatineditmode = true, dataformatstring = "{0:dd/mm/yyyy}")] public datetime date_of_birth { get; set; }
and @html.editorfor(x => x.date_of_birth)
helper display value respecting format defined.
if not using view models , cannot modify domain model use textbox helper:
@html.textbox("date_of_birth", model.date_of_birth.toshortdatestring())
Comments
Post a Comment