ASP.Net Core MVC date input value

后端 未结 2 573
礼貌的吻别
礼貌的吻别 2021-01-05 06:51

I created a edit view for a EF Model and have a problem with the datepicker. Whenever i try to edit a `dataset, the edit view don\'t show me the old date values.

Thi

2条回答
  •  时光说笑
    2021-01-05 07:33

    type="date" generates the browsers HTML-5 datepicker if supported. The specifications require that the value be formatted in ISO format (yyyy-MM-dd) which is then displayed in accordance with the browsers culture.

    Add the asp-format to format the value, and remove the value attribute (Tag Helpers correctly generate the value attribute for correct 2-way model binding and you should never attempt to add it yourself)

     
    

    Note the HTML-5 datepicker is not supported in IE, and only in recent versions of FireFox. If you want a consistent UI, then consider using a jQuery datepicker instead.

提交回复
热议问题