Solved

Problem with localization for international users

Posted on 2011-03-21
9
302 Views
Last Modified: 2012-06-21
I have a payment processing screen which work great for US based users. But for some users outside of US in Chile and Brazil, the amount of $95.00 comes in as $95,00 (with a coma) and that is processed as $9500.00 by Authorize.net.

Code is like this -
               string CCAmount = payment.Amount.ToString("#######.00");

How do I fix this localization issue.

Side note - Even the date came in as - '18-03-2011 16:23:24' but date is not a problem as I can handle that. I am not sure how to handle the amount part.
0
Comment
Question by:nsdlsandy
9 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 35181264
Sounds like you need to enforce a specific culture for your page:

   http://msdn.microsoft.com/en-us/library/bz9tc508(v=VS.80).aspx
0
 
LVL 1

Author Comment

by:nsdlsandy
ID: 35182052
I have this in the web.config

    <globalization requestEncoding="utf-8" responseEncoding="utf-8" enableClientBasedCulture="true" culture="auto" uiCulture="auto" />

According to the article above, this should take care of specific culture. Please let me know what else I should try.
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 200 total points
ID: 35182388
Auto lets the browser use it's current system settings to decide. Whereas it seems like you want to force it into US format, in which case you would set it to en-US rather than auto
0
 
LVL 23

Accepted Solution

by:
wdosanjos earned 300 total points
ID: 35182548
Try this:

System.Globalization.CultureInfo usCulture = new System.Globalization.CultureInfo("en-US");
string CCAmount = payment.Amount.ToString("#######.00", usCulture);

Open in new window


I hope this helps.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:nsdlsandy
ID: 35194234
carl_tawn,

I changed web.config entry -
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" enableClientBasedCulture="false" culture="en-US" uiCulture="en-US" />

Still it is showing the comma in the currecy. Please see the attached screen shot. I am able to replicate this issue by changing the Language to Spanish(Chile) in the browser. Please let me know what else I can try.

thanks
SM
 Comma-in-Currency

Without Comma , the currency with English(United States) comes right as shown below

 Without-Comma-in-Currency
0
 
LVL 1

Author Comment

by:nsdlsandy
ID: 35194313
wdosanjos

Thanks for your suggestion. I will try to do the code change and test it out.

regards
SM
0
 
LVL 27

Expert Comment

by:Chinmay Patel
ID: 35236411

wdosanjos has given the perfect solution, only change I would suggest is to not to declare an extra variable[and if you are doing such conversion a lot then create a global instance]

string CCAmount = payment.Amount.ToString("#######.00", new System.Globalization.CultureInfo("en-US")); 

Open in new window


Regards,
Chinmay.
0
 
LVL 1

Author Closing Comment

by:nsdlsandy
ID: 35288271
Helped in solving my issue
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now