AEMLoviji
AEMLoviji

Reputation: 3257

localization in asp.net mvc

I have tables with decimal type fields on Server.
I have published my web site to my local machine and to server.
In server it takes . as decimal separator but on my local machine , is decimal separator.
So I have ignored , with javascript.
Instead of , I am writing . with javascript.
So you can see that I have problem.
So what is a best way to Parse string to decimal?

p.s : I have changed decimal field to string in model

we are using different cultures. But what I can do? Must I change my culture to server culture every time I will work with site?

Upvotes: 0

Views: 330

Answers (2)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039498

You could set the culture to match that of the client:

<system.web>
    <globalization culture="auto" uiCulture="auto" />
    ...

Upvotes: 2

kerrubin
kerrubin

Reputation: 1616

It may be caused by differents cultures.

You can use

Double d = 0;
Double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out d);

or

Double d = Double.Parse("1,0", NumberStyles.Any, CultureInfo.InvariantCulture);

namespace System.Globalization.

Upvotes: 0

Related Questions