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

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

r - Update two sets of radiobuttons reactively - shiny -