In my MVC application, I have many DateTime type properties , and I define a DataFormatString for each new property in this data type, as follows:
Model:
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime StartDate{ get; set; }
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime EndDate{ get; set; }
Instead, I think there is another way to define these DataFormatStrings for just one place, and immediately by creating a new class containing a constant value or using a web configuration, etc. So, in this case, what is the best way to use constant values, i.e. date format, etc. I am using the globalization string on my web.config, but I'm not sure if I am setting the DataFormatStrings date in web.config. Any help would be appreciated.
source
share