Note that there are some explanatory texts on larger screens.

plurals
  1. PODateTime in ViewModel shows up as DateTime.MinValue in Controller
    primarykey
    data
    text
    <p>I have a standard asp.net mvc 4 view with a form that has some editable fields, including a DataTime selection. When the form is posted back to the controller, the DateTime always shows up as the minimum value for DateTime 1/1/0001, even though a valid date is successfully sent to the client or selected on the client.</p> <p>I'm guessing the DefaultModelBinding is messing this up, but I'm not sure why or how. In my web.config I have the following for globalization:</p> <pre><code>&lt;globalization enableClientBasedCulture="true" uiCulture="auto" culture="auto"/&gt; </code></pre> <p>Here is my ActionResult in the controller that receives the post:</p> <pre><code>[HttpPost] public virtual ActionResult Edit(KBUser kbuser) { if (this.ModelState.IsValid) { //save the user m_userRepo.UpdateUser(kbuser); return RedirectToAction(MVC.Users.Index()); } else { return View(kbuser); } } </code></pre> <p>Here is the relevant part of the View:</p> <pre><code>@model KBMaxLive.Domain.KBUser @using (Html.BeginForm("Edit", "User", new { idUser = Request["idUser"] }, FormMethod.Post, new { id = "form" })) { &lt;fieldset&gt; &lt;legend&gt;@Engine.Resources.KBMaxLive.Account&lt;/legend&gt; &lt;div class="field-column-container"&gt; &lt;div class="field-column"&gt; &lt;div class="field-container"&gt; @Html.LabelFor(u =&gt; u.CreatedDate) @Html.TextBoxFor(u =&gt; u.CreatedDate, new { @class = "k-textbox", @readonly = "readonly" }) @Html.ValidationMessageFor(u =&gt; u.CreatedDate) &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/fieldset&gt; } </code></pre> <p>All properties of the model come in fine except for the datetime.<br> Any ideas on what's going wrong or how to debug this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload