Skip to main content

Posts

Showing posts from April, 2012

DateTime format and decimal or currency issue resoved using Custom model binders in MVC

Hi all, You can't keep yourself away from writing blog when you have faced an issue while development and you tried to solve it and finally you come across something interesting which finally resolved the issue Today's post is regarding the scenario which we face in day to day life (But i faced it for the first time today) where i had multilingual application running on telerik controls One of the page had DateTimePicker,We have "da-DK" (Danish) clients,When tried to save Date from one page,The page kept on giving error message "DateTime format is not valid" for this field (Typical MVC datetime validation error messgae) So scenario was in UI everything was coming as per culture,If i select date from DatePicker it was returning correct format,But still couldn't figure out what was wrong So let me cut the story short and tell you,Model binder was the key to success The code looks like following public class DateTimeModelBinder : IModelBinder