I'm encountering an irritating binding behavior for a DateTime bound to a textbox that is disabled. It always returns null.
My model has a DateTime? StartDate property... I've also tried just DateTime StartDate (without the '?').
I've tried the following:
Attempt #1:
<%: Html.TextBoxFor(model => model.StartDate, new { @disabled="true" })%>
Attempt #2:
<%: Html.EditorFor(model => model.StartDate, "DateDisabled")%>
where DateDisabled is a partial view defined like this:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DateTime?>" %>
<%: Html.TextBox("", Model.HasValue ? Model.Value.ToShortDateString() : "", new { @class = "text-box-short-disabled", @disabled = "true" })%>
All my attempts returns a null value. Is there something I missed? Or a workaround?