开发者

IIS 7 - determine decimal symbol

My IIS 7 server uses a C#.NET codefile to read from an MS SQL database (on another machine) and presents it on the web. I made a similar posting before, but the problem has resurfaced and I've not been able to fix it.

In this regard I've had a problem with my Norwegian Windows Server running IIS 7. It reads the columns from a database which returns some coordinates with decimals. 开发者_Python百科In the database I managed to change the decimal symbol from the Norwegian default (comma) to periods, by changing the windows settings.

I did the same thing on the Windows 2008 server running IIS 7, but it still translates the periods back to commas. I need it to be periods. I even changed the code to convert the rows to strings and then replace all commas with periods, but it still doesn't work.

Any help here would be greatly appreciated.


First things first - I'm assuming you mean something like ASP.NET Web Forms, right?

If so, then in the web.config, have you set:

<globalization culture="auto"/>

If you've done that, and you're getting some problems still, it might be that the language settings as defined in the browser are wrong. Check those.

You can omit the above web.config line if you don't care about detecting the user's locale, and always displaying decimals according to their preferences.

You can change that line to the following:

<globalization culture="NN-NO"/>

... to force your web application to always use Norwegian Bokmål (Norway) (NN-NO) as it's default culture, which should force the decimals to display the way that you need.

As an alternative, you can choose to format any decimals on screen according to a particular format, using NumberFormatInfo, as in my example below:

NumberFormatInfo ni = Globalization.CultureInfo.GetCultureInfo("NB-NO").NumberFormat; 
Decimal.ToString("c", ni); 

Hope this helps,

Richard.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜