Hi,
My web application has to support different cultures for displaying the price values.
For example,
if german user is using application then price value has to be displayed like 1,05 [decimal separater is comma, thousand separater is dot]
if chines user is using application then price value has to be displayed like 1.05 [decimal separater is dot, thousand separater is comma]
I will call the application[set language German] from my browser after configuring the application.This language has been set my application whereever i calling the application. So other language is not working to display the price value.
Note:
Is there any default language setting in IIS if access the first time?
or
For accessing database, i am using BORLAND.DATA.ADODBXCLIENT.dll to access the interbase database in my web application. Is it any default language setting when access the database? I saw the log, if set de-DE when access first time then the price has been logged like 1,05. When i change the my language for en-EN in my browser then the price has been logged like 105.
Loading
Ramesh KumarPosted Nov 19, 2010, 11:16 PM
I got solution to show the number format in different culture.
Changes in Web.Config:
<globalization enableClientBasedCulture="true" culture="de-DE" uiCulture="auto"/>
· culture="de-DE" will set the language in which the Database will fetch the records, for e.g: if Database is of "de-DE" language then culture should be in "de-DE".
· uiCulture="auto" will consider the language set in Clients browser for User Interface.
Page Level Changes:
Old Code: [Current Browser Culture will be set to Page Culture]
protected void Page_Init(object sender, EventArgs e)
{
System.Globalization.CultureInfo pageCultureInfo = System.Globalization.CultureInfo.CurrentCulture;
Page.Culture = pageCultureInfo.Name.ToString();
}
New Code: [Current Browser Culture will be set to Page UICulture]
protected void Page_Init(object sender, EventArgs e)
{
System.Globalization.CultureInfo pageCultureInfo = new CultureInfo(ApplicationConstants.RegionalSettings, false);
Page.UICulture = pageCultureInfo.Name.ToString();
}
Solution Status:
The Property Data type of in Class will be same as the Table field Data type
· For Price and Weight fields
o If data type of property is string the format is applied perfectly
o If data type of property is double the formatting has problem
drOrder["Purchase_Price"] value is set to "1,50" in database
double dblPrice = Convert.ToDouble(drOrder["Purchase_Price"])
dblPrice à shows "1.50"
dblPrice.ToString() àshows "1,50"
when binding to coolite grid it displays "1.50" instead of "1,50"
§ checked with forums http://msdn.microsoft.com/en-us/library/system.convert.todouble(VS.71).aspx
Ramesh KumarPosted Nov 11, 2010, 5:54 AM
I think, I was trying to log the price value in text file where the value is getting wrong by using reader. If the DE language is set when access the application in firsttime then get the price value is 1,05 . So it is working fine whereever the user browser language is DE. If the user will change the language EN and access this page then get the price value is 105. So reader gets the value is wrong.
This was i logged in a textfile in my application.
Is there any default language setting in IIS if access the first time?
Jean PaulPosted Nov 11, 2010, 4:52 AM
(This might be the case for problem)
I have created a short step by step tutorial for testing this. You can try the following url.
http://jeanpaulva.wordpress.com/2010/11/11/asp-nethow-to-format-currency-based-on-users-browser-setting/
Ramesh KumarPosted Nov 11, 2010, 2:57 AM
Thank you for your reply.
I tried this method to showing the price value. It is not working.
Jean PaulPosted Nov 11, 2010, 2:50 AM
CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(this.Request.UserLanguages[0]);
double value = 1000;
string formattedValue = value.ToString("C", cultureInfo.NumberFormat);