Solved

Problem with localization for international users

Posted on 2011-03-21
9
303 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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
 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 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