Format Date On Binding (ASP.NET MVC)

后端 未结 12 936
感情败类
感情败类 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:09

    I find the best way to do this is to reset the ModelValue

    ModelState.SetModelValue("due", new ValueProviderResult(
           due.ToShortDateString(), 
           due.ToShortDateString(), 
           null));
    

提交回复
热议问题