Solved

Problem with localization for international users

Posted on 2011-03-21
9
301 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Author Comment

by:nsdlsandy
Comment Utility
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
Comment Utility
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
Comment Utility

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
Comment Utility
Helped in solving my issue
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

743 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

15 Experts available now in Live!

Get 1:1 Help Now