Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataAnnotation to display month name

How to display the full month name and year in DataFormatString?(November-2014)

I tried using this DataAnnotation,but it does not give me the desired o/p:

 [DisplayFormat(DataFormatString="0:MMMM-yyyy")]
like image 339
Sumedha Vangury Avatar asked Feb 11 '23 12:02

Sumedha Vangury


1 Answers

I don't know it makes a difference or not but how about;

[DisplayFormat(DataFormatString = "{0:MMMM-yyyy}")]

From DisplayFormatAttribute.DataFormatString property

The formatting string can be any literal string and usually includes a placeholder for the field's value. For example, in the formatting string "Item Value: {0}", the field's value is substituted for the {0} placeholder when the string is displayed in the DynamicField object. The remainder of the formatting string is displayed as literal text.

If the formatting string does not include a placeholder, the field's value from the data source is not included in the final display text.

like image 112
Soner Gönül Avatar answered Feb 14 '23 02:02

Soner Gönül