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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -