我有一個包含某些日期和時間屬性的模型。與@ Html.TextBoxFor()一起使用時,DisplayFormat屬性的DataFormatString參數不起作用
的時間屬性有下列DataAnnotation:
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:hh:mm tt}")]
和日期的屬性有:
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]
然而,當我使用@Html.EditorFor()
而不是@Html.TextBoxFor()
這些只是尊重。
我目前的情況不會允許我使用EditorFor
,那麼我如何強制TextBoxFor
尊重這些格式字符串?
爲什麼你必須使用'TextBoxFor'? – DarthVader
驗證無法正確使用'EditorFor's。我們一直在調查沒有出現。 – Kehlan
驗證可能與您在應用中使用的'CultureInfo'有關。 – DarthVader