I was wondering if there was any way to directly change the format of a date displayed in a TextAreaFor. I know this topic has been asked alot and my problem may seem similar to those two:
MVC DateTime Textbox Formatting Issue
How do you format a DateTime that's displayed by TextBoxFor() in MVC3?
But I will explain why its different. Here's the textarefor :
@Html.TextAreaFor(m => m[i].DateFormation, new { @class = "textArea" })
Like in the questions I linked above, I could put the DisplayFormat attribute on the field but I don't have the right to modify the model or use Metadata
So My question is if there is any way to apply a format to a textareafor like you can do with a textboxfor ?
@Html.TextBoxFor(m => m[i].DateFormation, "{0:yyyy-MM-dd}", new { @class = "textArea" })
I Tried to apply .ToString
to my field but it seems like TextAreafor won't accept it
Note : My last case scenario is that I will Have to modify the model content with c# code in view before showing it but that just feels wrong to me and a bad practice to mix my code with the design
After Searching for Sometimes and looking into documentation ( Thanks to @StephenMuecke for the clue) TextAreaFor
just dosen't have any option that support formating so ill just be using code before showing the date so that the time isen't shown.
I Looked into most overload and option shown for textarea on this msdn link : https://msdn.microsoft.com/en-us/library/system.web.mvc.html.textareaextensions(v=vs.118).aspx
And as shown in the link the only possible overload for TextAreaFor are related to the model and none of them could accept a property to change the formating