1

How is formatted user input typically handled in an MVC application? A user entering "1,000.00" for a number for example. I'm somewhat surprised the default ModelBinder does not pick up on this. Would this be the type of thing I would create my own ModelBinder for?

1 Answer 1

2

I think that DefaultModelBinder use CultureInfo.CurrentCulture to parse numeric data.

Sign up to request clarification or add additional context in comments.

2 Comments

It depends on the CurrentCulture of your app. You can check it or chage it by changing the property System.Threading.Thread.CurrentThread.CurrentCulture. For example: if the culture is en-US, then value like 9,876,543,210,987,654.3210 should be properly parsed to Double or Decimal value 9876543210987654.3210.
I think the value is not parsed. It is converted. (ValueProviderResult -> ConvertSimpleType in the MVC source). The last time I had some problems with decimal this realy made a difference. See TypeConverter Class in msdn.microsoft.com/en-us/library/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.