Reputation: 12855
My form post with fiddler is that:
Name=testdate4&CreatedAt=Thu+Jan+01+1970+01%3A00%3A00+GMT%2B0100+(Mitteleurop%C3%A4ische+Zeit)
So the CreatedAt date is sent with the hidden field correctly.
But in my action:
[HttpPost]
public ActionResult Create(TemplateViewModel templateViewModel)
{
}
public class TemplateViewModel
{
public string Name { get; set; }
public DateTime CreatedAt { get; set; }
}
The Name is sent and mapped to the Name property but the CreatedAt property is not mapped to the hidden field, why?
Upvotes: 0
Views: 1592
Reputation: 850
I have this issue before, and is because my browser accept different date format from the server culture.
For e.g. I set my datepicker in browser to accept dd/mm/yy format but in server default culture is en-US. Even though you manage to see value in fiddler but you can't get it in controller.
So what i do last time is add this to web.config, then everything will work.
< system.web> < globalization culture="en-GB" uiCulture="en-GB" /> < / system.web>
If you like to refer to date sample, this may help.
Upvotes: 1