Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.

 

 

 

 

 

 

 

Sys.CultureInfo.numberFormat Field

Gets an object that contains an array of culture-sensitive formatting and parsing strings values that can be applied to Number type extensions.

Syntax

var cultureObject = Sys.CultureInfo.CurrentCulture;
var nfObject = cultureObject.numberFormat;

Return Value

An object that contains an array of culture-sensitive formatting strings.

Remarks

Use the numberFormat field to retrieve an object that contains an array of formatting strings that are based on the current culture or on the invariant culture. Each formatting string can be used to specify how to format Number type extensions.

Example

The following example shows how to use the numberFormat field of the Sys.CultureInfo class based on the current culture. The culture attribute of the <configuration> section in the Web.config file must also be set to "auto". For more information about culture settings, see Globalizing a Date by Using Client Script.

cs

<script type="text/javascript">
    // Create the CurrentCulture object
    var cultureObject = Sys.CultureInfo.CurrentCulture;
// <Snippet4>
    // Get the name field of the CurrentCulture object
    var cultureName = cultureObject.name;
// <Snippet5>
    // Get the numberFormat object from the CurrentCulture object
    var nfObject = cultureObject.numberFormat;
    // Create an array of format types
    var myArray = ['CurrencyDecimalDigits', 'CurrencyDecimalSeparator', 'IsReadOnly', 'CurrencyGroupSizes',
                   'NumberGroupSizes', 'PercentGroupSizes', 'CurrencyGroupSeparator', 
                   'CurrencySymbol', 'NaNSymbol', 'CurrencyNegativePattern', 'NumberNegativePattern', 
                   'PercentPositivePattern', 'PercentNegativePattern', 'NegativeInfinitySymbol', 
                   'NegativeSign', 'NumberDecimalDigits', 'NumberDecimalSeparator', 
                   'NumberGroupSeparator', 'CurrencyPositivePattern', 'PositiveInfinitySymbol', 
                   'PositiveSign', 'PercentDecimalDigits', 'PercentDecimalSeparator', 
                   'PercentGroupSeparator', 'PercentSymbol', 'PerMilleSymbol', 
                   'NativeDigits', 'DigitSubstitution'];

    var result = 'Culture Name: ' + cultureName;
    for (var i = 0, l = myArray.length; i < l; i++) {
        var arrayVal = myArray[i];
        if (typeof(arrayVal) !== 'undefined') {
            result += "<tr><td>" + arrayVal + "</td><td>" + eval("nfObject." + arrayVal) + '</td></tr>';
        }
    }
    var resultHeader = "<tr><td><b>FormatType</b></td><td><b>FormatValue</b></td></tr>"
    $get('Label1').innerHTML = "<table border=1>" + resultHeader + result + "</table>";

    var n = 99.987;
    $get('Label2').innerHTML = "<p/><h3>numberFormat Example: </h3>" + 
    n.localeFormat("C");

 </script>

vb

<script type="text/javascript">
    // Create the CurrentCulture object
    var cultureObject = Sys.CultureInfo.CurrentCulture;
// <Snippet4>
    // Get the name field of the CurrentCulture object
    var cultureName = cultureObject.name;
// <Snippet5>
    // Get the numberFormat object from the CurrentCulture object
    var nfObject = cultureObject.numberFormat;
    // Create an array of format types
    var myArray = ['CurrencyDecimalDigits', 'CurrencyDecimalSeparator', 'IsReadOnly', 'CurrencyGroupSizes',
                   'NumberGroupSizes', 'PercentGroupSizes', 'CurrencyGroupSeparator', 
                   'CurrencySymbol', 'NaNSymbol', 'CurrencyNegativePattern', 'NumberNegativePattern', 
                   'PercentPositivePattern', 'PercentNegativePattern', 'NegativeInfinitySymbol', 
                   'NegativeSign', 'NumberDecimalDigits', 'NumberDecimalSeparator', 
                   'NumberGroupSeparator', 'CurrencyPositivePattern', 'PositiveInfinitySymbol', 
                   'PositiveSign', 'PercentDecimalDigits', 'PercentDecimalSeparator', 
                   'PercentGroupSeparator', 'PercentSymbol', 'PerMilleSymbol', 
                   'NativeDigits', 'DigitSubstitution'];

    var result = 'Culture Name: ' + cultureName;
    for (var i = 0, l = myArray.length; i < l; i++) {
        var arrayVal = myArray[i];
        if (typeof(arrayVal) !== 'undefined') {
            result += "<tr><td>" + arrayVal + "</td><td>" + eval("nfObject." + arrayVal) + '</td></tr>';
        }
    }
    var resultHeader = "<tr><td><b>FormatType</b></td><td><b>FormatValue</b></td></tr>"
    $get('Label1').innerHTML = "<table border=1>" + resultHeader + result + "</table>";

    var n = 99.987;
    $get('Label2').innerHTML = "<p/><h3>numberFormat Example: </h3>" + 
    n.localeFormat("C");

 </script>