I have the following model and view, and I would very much like to accept the date values in the format "dd / MM / yyyy". However, despite using annotations DisplayFormat, I still get a validation error using my selected format.
[MetadataType(typeof(MilestoneMetadata))]
public partial class Milestone {
public class MilestoneMetadata {
[Required][DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public object Date { get; set; }
}
}
and view:
<div class="editor-field">
<%: Html.EditorFor(model => model.Date) %>
<%: Html.ValidationMessageFor(model => model.Date) %>
</div>
Namespaces etc. true for annotations and core classes that are in the same namespace. This is not my first encounter with this problem, but I do not see the results of annotations, which should affect the comparisons between the values of the form and the model. The template for dates does not help me, because I cannot find a way to establish how dates are processed when publishing a creation or update.
. .