localization RRS feed

  • Question

  • User-1773948845 posted

    I have a textbox which accepts a numeric value with decimals

    Here is the scenerio.

    I am using windows locale US.

    So a decimal operator is used as dot (.) only.

    Now I change the windows locale is Brazil

    Now the decimal operator used for Brazil is comma(,)

    What i require ?

    Even though i change the locale i wanted the decimal operator to be used is dot(.) only.

     How do i impelement it ?

    Help would be more appericated.


    Tuesday, November 21, 2006 6:51 AM

All replies

  • User1622957740 posted


    You need to override the Culture settings on the active Culture to make this happen. Unfortunately this means you have to reassign a new culture info object.

     You can do this on your page in InitializeCulture, or earlier in Application_PreRequestHandlerExecute in Global.asax to do it more globally. The following code should do the trick:

    protected override void InitializeCulture()
        System.Globalization.CultureInfo Culture = new System.Globalization.CultureInfo("pt-BR");
        System.Threading.Thread.CurrentThread.CurrentCulture = Culture;
        System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator = ".";
        System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyGroupSeparator = ",";       


    Hope this helps,


    +++ Rick --- 

    Tuesday, November 21, 2006 3:29 PM
  • User-1773948845 posted

    What we are trying in the above code?

    Are we setting the culture to ("pt-br") and overriding the currencydecimalsepator to dot (.) instead of default separator comma(,)

    after writing this code, if i change the locale to brazil my input character will be dot for decimal and not comma(,)

    If this happens i would be more happy.


    Tuesday, November 21, 2006 11:56 PM
  • User1622957740 posted

    Any changes you make to the active Culture or UICulture requires that you reset the culture because the default culture is ReadOnly. Now I don't know what locale you want to set but you have to set some locale. If you don't know what the locale is you can read it of the current culture with the Name property and use that for creating the new CultureInfo.

    I'm not sure exactly what you need to set or which way to set it but what I posted above should let you experiment and find the right combination.

    +++ Rick ---

    Wednesday, November 22, 2006 12:12 AM
  • User539966898 posted
    Well if you want your whole site to be set for Brazil you can add this setting in your web.config. hope this help

    <globalization culture="pt-br" uiCulture="pt-br"/>


    Wednesday, November 22, 2006 4:35 PM
  • User-1773948845 posted

    Thats good.This is what i wanted

    After making the globization to "pt-br" the decimal opeartor would be comma(,) and not the decimal dot(.)

    Now i want to override the feature by making dot(.) as the default operator invariably of any windows locale.

    can this be achieved.

    Hoping for a better solutions.


    Wednesday, November 22, 2006 10:49 PM