Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

German UI Culture de-DE decimal changing to comma value issue in asp.net

Tags:

c#

asp.net

I am using german UI Culture in my asp.net application. I am changing my application's UI culture based on the language selected in the dropdown, on dropdown selected index change i am using this code

Thread.CurrentThread.CurrentCulture = new CultureInfo(this.lstLanguage.SelectedValue);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(this.lstLanguage.SelectedValue);

the Dropdown is as below

<asp:DropDownList cssClass="ddllanguage" ValidationGroup="b" runat="server" ID="lstLanguage" AutoPostBack="True"  OnSelectedIndexChanged="LstLanguage_SelectedIndexChanged" meta:resourcekey="lstLanguage">                    
  <asp:ListItem Value="en-US" Text="English" meta:resourcekey="ListItemResource2" ></asp:ListItem>
  <asp:ListItem Value="de-DE" Text="Deutsch" meta:resourcekey="ListItemResource3"></asp:ListItem>
</asp:DropDownList>

My problem is after changing the language to de-DE all the decimal values in my application are being changed as comma, all the decimal number like 5.12 is coming as 5,12 all the decimal values are changed to comma. How to get decimal values as it is without comma.

like image 410
Kumar Gaurav Avatar asked Jun 29 '12 10:06

Kumar Gaurav


1 Answers

Thread.CurrentUICulture is intended to be used for User Interface, it's the language used to display text, orientation and so on.
Thread.CurrentCulture is intended to be used for parsing/formatting stuffs. Date and time, numbers and string comparison (for example).

If you want to change only UI language (and to keep everything else with the culture of your web server) you have to modify only Thread.CurrentUICulture.

like image 103
Adriano Repetti Avatar answered Sep 21 '22 00:09

Adriano Repetti