Reputation: 2792
For some reason the format of the code below is still displayed as dd/mm/yyyy.
<div class="col-4">
@Html.TextBoxFor(m => m.BeginDatum, "{0:dd-MM-yyyy}", new { id = "BeginDatum", @class = "form-control float-left key", placeholder = "dd-mm-jjjj" })
</div>
In the viewmodel:
[Mandatory]
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}")]
public string BeginDatum { get; set; }
We are using MVC v5.2.3.
It makes no difference
Upvotes: 0
Views: 234
Reputation: 2792
[Mandatory]
[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}")]
public DateTime BeginDatum { get; set; }
Found the problem. The type was string and should be DateTime.
Upvotes: 1