开发者

ASP.Net: Setting the correct currency settings for string.Format()

In my ASP.Net Website I am using

String.Format("{0:C}", param)  

to format curren开发者_Go百科cy values. On my local machine this works great, but when deploying the website to the server the output switches from € to $.

Obviously the server has different Culture settings, is there an easy way to change this application wide? (without direct access to the servers settings)

Is there an web.config entry I can change?


You can do this in web.config

http://msdn.microsoft.com/en-us/library/bz9tc508.aspx

In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page.

Example

<globalization uiCulture="es" culture="es-MX" />


        var culture = new CultureInfo("en-us");
        culture.NumberFormat.CurrencyDecimalDigits = 3;
        Trace.WriteLine(Cost.ToString("c", culture));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜