Sys.CultureInfo.numberFormat, propriété
Mise à jour : novembre 2007
Obtient un objet qui contient un tableau de valeurs de chaîne de mise en forme et d'analyse dépendantes de la culture qui peuvent s'appliquer aux extensions de type Number.
var cultureObject = Sys.CultureInfo.CurrentCulture;
var nfObject = cultureObject.numberFormat;
Valeur de retour
Objet qui contient un tableau de chaînes de mise en forme dépendantes de la culture.
Notes
Utilisez le champ numberFormat pour récupérer un objet qui contient un tableau de chaînes de mise en forme basées sur la culture actuelle ou sur la culture indifférente. Chaque chaîne de mise en forme peut être utilisée pour spécifier la mise en forme des extensions de type Number.
Exemple
L'exemple suivant montre comment utiliser le champ numberFormat de la classe Sys.CultureInfo selon la culture actuelle. L'attribut culture de la section <configuration> dans le fichier Web.config doit également avoir pour valeur « auto ». Pour plus d'informations sur les paramètres de culture, consultez Procédure pas à pas : globalisation d'une date à l'aide d'un script client.
<script type="text/javascript">
// Create the CurrentCulture object
var cultureObject = Sys.CultureInfo.CurrentCulture;
// Get the name field of the CurrentCulture object
var cultureName = cultureObject.name;
// 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>
<script type="text/javascript">
// Create the CurrentCulture object
var cultureObject = Sys.CultureInfo.CurrentCulture;
// Get the name field of the CurrentCulture object
var cultureName = cultureObject.name;
// 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>