Format Date On Binding (ASP.NET MVC)

后端 未结 12 815
感情败类
感情败类 2021-01-31 08:46

In my ASP.net MVC app I have a view that looks like this:

...

<%=Html.TextBox(\"due\")%>
...

I am usi

12条回答
  •  没有蜡笔的小新
    2021-01-31 09:16

    I found this question while searching for the answer myself. The solutions above did not work for me because my DateTime is nullable. Here's how I solved it with support for nullable DateTime objects.

    <%= Html.TextBox(String.Format("{0:d}", Model.Property)) %>
    

提交回复
热议问题