Display a formatted date in a TextBoxFor()

前端 未结 6 1713
长情又很酷
长情又很酷 2020-12-04 18:52

I\'m using MVC4 and Entity Framework to develop an intranet web app. I have a list of persons which I can edit. When I access the edit view, in the textbox \"Start date\", t

6条回答
  •  独厮守ぢ
    2020-12-04 19:33

    try this.. convert the date value as a htmlAttribute within textboxfor.. that can solve your problem

    @Html.TextBoxFor(model => model.StartDate, new { htmlAttributes = new { @Value = Model.StartDate.ToString("yyyy/MM/dd"), type = "date" }}) @Html.ValidationMessageFor(model => model.StartDate)

提交回复
热议问题