Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

ASP.NET–How to format currency based on user’s browser setting

Posted by Paul on November 11, 2010

Hello All.  In this example I am trying to show how to format currency based on user’s browser setting.

Our aim is to show them the formatted currency like:

Format Language
$1,000.00 United States
1,000.00د.إ.‏ Arabic
R$ 1.000,00 Portugese
1.000,00 TL Turkish

Step 1: Create the ASP.NET Application

Create a new web application and on the default page place a button and label.

On the button click you can add the following code.

protected void Button1_Click(object sender, EventArgs e)


    CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(this.Request.UserLanguages[0]);


    double value = 1000;

    Label1.Text = value.ToString("C", cultureInfo.NumberFormat);


The code collects the user language from Request object and uses the ToString() method to format the value.

That finishes the coding part.. Now you have to see the things working.  For this you have to run the application and test it by changing the browser language.  I will guide you through it.

Step 2: Execute the application

You can execute the application and see the page opened in your browser.


Try clicking the button and you can see the number formatted in current language.

Step3: Change Browser Language

In this step we have to change the browser language.

If you are using Internet Explorer choose Internet Options screen.


Click the Languages button on the bottom and you can see the following screen.


Click the Add button to add a new language.  Select Arabic, move it up using the “Move up” button and click Ok.


Now you are ready to test the code in Arabic.

Click the “Change Format” button again and you can see the number format in Arabic.


Note: After changing the languages to back in browser you might need to restart it.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s