I have an very frustrating issue in a simple web application I am building.
It works fine in chrome and firefox, but when using the application in Safari on an ipad (which is where it will be used in live) the data is not being formatted correctly.
For example, the data retrieved definitely uses a point (.
) as a decimal seperator, and appears as such in firefox/chrome.
However, when viewing the data in safari, it appears as a comma (,
) and this is messing up my database inserts.
I tried changing my region and language to United Kingdom but with no effect.
This is how I display one of the decimals in question:
@Html.LabelFor(model => model.MassOff, new { @class = "viewFieldLabel" }) <br />
@Html.DisplayFor(model => model.MassOff)
But it is even worse that this, as I also display decimals elsewhere in a WebGrid
, which automatically populates itself based on class properties, so I never explicitly tell it to display the decimal. However, it still appears with a comma in the WebGrid
so I ahve no idea how I'm going to change that...
Why would safari do this automatically, when I have at no point asked it to convert any formats? Do I now have to manually try and find all these values and change them using JQuery (which seems absolutely ridiculous), or is there some setting I can change on the ipad or property I need to include in my code?
Update
I managed to fix the way the decimals are displayed with a
[DisplayFormat(DataFormatString = "{0:0.###}")]
Above the properties in question. However, when submitting data, it is still being sent through with a comma (,
), so it seems this only changes the way it is displayed.