我想知道是否有任何方法可以直接更改TextAreaFor中顯示的日期格式。我知道這個話題已經被問了很多和我的問題可能看起來類似於二:直接在TextAreafor上更改日期顯示格式
MVC DateTime Textbox Formatting Issue
How do you format a DateTime that's displayed by TextBoxFor() in MVC3?
但我會解釋爲什麼它的不同。 這裏的textarefor:
@Html.TextAreaFor(m => m[i].DateFormation, new { @class = "textArea" })
就像我上面鏈接的問題,我可以把DisplayFormat屬性的字段,但我沒有修改模型或使用元數據
所以正確的我問題是,如果有什麼方法可以將文本應用於文本框,就像使用文本框一樣?
@Html.TextBoxFor(m => m[i].DateFormation, "{0:yyyy-MM-dd}", new { @class = "textArea" })
我嘗試申請.ToString
我的領域,但它似乎像TextAreafor不會接受
注:我最後的情況是,我將不得不修改與視圖的C#代碼模型內容在顯示它之前,但對我來說只是感覺不對,而且將我的代碼與設計混合使用的做法很糟糕
'TextAreaFor()'不支持格式。但爲什麼你用'