Hi guys, I thought I'd take the original currency discussion thread to the developer forum where it belongs.
So using Joe's technique of forcing site culture (en-US) on the displayed amount, the currency symbol is displayed correctly as $, regardless of browser culture. However, I have a separate text box where the user enters the amount they are going to pay (this box defaults with the current amount due, again in site culture format). After my changes, it all looks right. They could have an amount due of $155.67, and that will display as the amount due, and the amount to pay box will default with 155.67. All good so far.
Now, if I have my browser language set to es-ES, or even the generic es, performing the currency conversion on a defaulted or entered amount of "155.67" results in a displayed amount to pay of $15,567.00. I know this is due to the browser culture specifying "," for the decimal separator and "." for the thousands separator. If I set my browser to Spanish U.S. (es-US) or Spanish Mexico (es-MX) it uses "," for thousands and "." for decimal, just like USD, and everything works as expected.
I guess theoretically it's up to the user to be aware of the culture they are using, and adjust entry accordingly, but it seems very confusing because the USD conversion of displayed amounts is showing #.##, although it seems to expect entry in #,## format.
Here is a code snippet so hopefully someone can give me a pointer on what to change.
currencyCulture = ResourceHelper.GetCurrencyCulture(siteSettings.GetCurrency().Code);
lblAVAmtDueVal.Text = acct.AcctBase.CurrentAmt.ToString("C", currencyCulture);
suggAmtToPay = acct.AcctBase.CurrentAmt - pendingPymts;
if (suggAmtToPay <= 0)
suggAmtToPay = 0;
lblAVAmtToPayWarn.Visible = true;
tbAVAmtToPay.Text = suggAmtToPay.ToString("F", currencyCulture);
// Validation of entered tbAVAmtToPay.Text here
lblCIAmtToPayDispVal.Text = decimal.Round(decimal.Parse(tbAVAmtToPay.Text), 2).ToString("C", currencyCulture);
Has anyone else faced a situation like this? Boy, I sure feel fortunate that I haven't had to struggle with this all along. Globalization is tough!