Convert Date To ToShortDateString In Razor -


i have datetime field must shown in edit view

@html.editorfor( model => model.startdate ) 

how can use somthing ;

@html.editorfor( model => model.startdate.toshortdatestring() ) 

or custom function changing datetime view.

use [displayformat] attribute on view model:

public class myviewmodel {     [displayformat(dataformatstring = "{0:d}", applyformatineditmode = true)]     public datetime startdate { get; set; }      ...  } 

and in view simply:

@model myviewmodel ... @html.editorfor(model => model.startdate) 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -