How to globalize ASP.NET MVC views (decimal separators in particular)?

Posted by Pawel Krakowiak on Stack Overflow See other posts from Stack Overflow or by Pawel Krakowiak
Published on 2009-04-17T12:43:12Z Indexed on 2010/05/24 10:31 UTC
Read the original article Hit count: 226

Filed under:
|

I'm working with the NerdDinner sample application and arrived at the section which deals with the Virtual Earth map. The application stores some values for the longitude and latitude. Unfortunately on my system floating point numbers are stored with a comma as the decimal separator, not a dot like in the US. So if I have a latitude of 47.64 it's retrieved and displayed as 47,64. Because that value is passed in a function call to the Virtual Earth API it fails at that point (e.g. JavaScript API expects 47.64, -122.13, but gets 47,64, -122,13).

I need to make sure that the application always uses dots. In a WebForms app I would have a common class which overrides the System.Web.UI.Page.InitializeCulture() method and I would be inheriting my pages from that class.

I am not sure about how to do the same with MVC. Do I need a customized ViewPage or something? Is there an easy way to solve this? Examples?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about globalization