show only the date in @Html.EditorFor helper

后端 未结 4 1306
名媛妹妹
名媛妹妹 2020-12-04 00:33

I am trying to populate @Html.EditorFor helper. I have created a view model with the below property

[DataType(DataType.Date, ErrorMessage="D         


        
4条回答
  •  广开言路
    2020-12-04 01:19

    I would make your view model's YearBought property a String for the easiest manipulation. The server can format the date, it can do the parsing on postback, and you can still use the DataType.Date data annotation for jQuery validation. This also ensures that the display value will be exactly what you want prior to being submitted to the view.

提交回复
热议问题