I have an input form that is bound to a model. The model has a TimeSpan property, but it only gets the value correctly if I enter the time as hh:mm or hh:mm:ss. What I want is for it to capture the value even if it’s written as hhmm or hh.mm or hh.mm.ss or … I want many different formats to be parsed correctly. Is this possible?
Thanks!
Yes – write a custom model binder for your model object. There’s an thread about just that subject here on SO: ASP.NET MVC2 – Custom Model Binder Examples