in asp.net MVC 2 /beta Date format issue: The value is not valid
in asp.net mvc 2 or bet开发者_JS百科a , model not accepting the date 13 ( more than 12'th of date) . Model showing error ads
" The value '20/10/2010' is not valid for MyDateFieldName "
what have to do? Model showing false status as ModelState=False. why?
By default the model binder uses the InvariantCulture to parse DateTime and invariant is mm/dd/yyyy whereas you are using the European dd/mm/yyyy format. You could override the model binder for types of DateTime to use dd/mm/yyyy though this will have internationalisation issues (though in my opinion so does the choice of Invariant Culture, I'd have made either of the xx/xx/xxxx variants invalid without explicitly turning it on). You could override the model binder to parse in based on the client's culture settings (though if you are using datepickers you have more places to worry about it). Alternatively you could have your DateTimes taken in as yyyy/mm/dd format as as far as I know yyyy/dd/mm is not recognised by any other cultures and will be universally acceptable.
精彩评论