I have a model with two dates, I pass both in as Proposed "08/07/2013 08:00:00" and CurrentFocusDate "08/07/2013 00:00:00" however somewhere something is going wrong as in the page they are rendered differently (see output below) Anyone have an idea why two alsmot identical properties would get rendered differently?
Model
public AdminNoteViewModel
{
[HiddenInput(DisplayValue = false)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime ProposedDateTime { get; set; }
[HiddenInput(DisplayValue = true)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime CurrentFocusDate { get; set; }
[HiddenInput(DisplayValue = true)]
public string NavigationLink { get; set; }
}
View
@Html.EditorFor(model => model.ProposedDateTime)
@Html.ValidationMessageFor(model => model.ProposedDateTime)
@Html.EditorFor(model => model.CurrentFocusDate)
@Html.HiddenFor(model => model.NavigationLink)
Controller
public ActionResult AddNote(DateTime proposedEventDateTime, long productId, DateTime currentFocusDate, string navigationLink)
{
var model = new AdminNoteViewModel
{
ProductId = productId,
ProposedDateTime = proposedEventDateTime,
CurrentFocusDate = currentFocusDate,
NavigationLink = navigationLink
};
return View(model);
}
This is the source rendered
<input data-val="true" data-val-date="The field ProposedDateTime must be a date." data-val-required="The ProposedDateTime field is required." id="ProposedDateTime" name="ProposedDateTime" type="hidden" value="07/08/2013 08:00:00" />
<span class="field-validation-valid" data-valmsg-for="ProposedDateTime" data-valmsg-replace="true"></span>
<input data-val="true" data-val-date="The field CurrentFocusDate must be a date." data-val-required="The CurrentFocusDate field is required." id="CurrentFocusDate" name="CurrentFocusDate" type="hidden" value="08/07/2013 00:00:00" />
<input id="NavigationLink" name="NavigationLink" type="hidden" value="Civica.DrugAdmin.UI.Models.AdminNoteViewModel" />
When I debug, the model osted to the view has both dates correctly formatted, however when they render on the page one of the them (currentFocusDate) gets switched around.