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
- in which browser the page is shown.
- when the DisplayFormatAttribute is removed.
- when the format is removed from the TextBoxFor.
Found the problem. The type was string and should be DateTime.