c# - send DateTime through a Ajax.BeginForm #c -
i'm trying use ajax.beginform. want send datetime through html form. problem in controller datetime not initialised. default datetime. idea ? help.
my model:
public class testmodel { public objectid _id { get; set; } public datetime mydate { get; set; } }
my action in testcontroller
[httppost] public void updatetest(testmodel tmp) { tmp.mydate.date <-- wrong date ... ... }
my view
@model project.models.testmodel @using (ajax.beginform(new ajaxoptions() { httpmethod = "post", url = url.action("updatetest", "test") })) { @html.textboxfor(model => model._id) @html.textboxfor(model => model.mydate) // example : 18/05/2013 17:00:00 <input type="submit" value="submit" /> }
javascript
<script type="text/javascript" src="/scripts/jquery.unobtrusive-ajax.min.js"> </script>
you must create custom model binder datetime , register on global.asax
Comments
Post a Comment