Custom culture of Textbox
I have a currency textbox , where the currency is in french language (using ',' instead of ',' and vice versa)
I added MaskedEditExtender but automatically it translated the '.' into a space! Here you are the code:
MaskedEditExtender oMaskedEditExtender = new MaskedEditExtender();
oMaskedEditExtender.ID = "MEE" + txtMoney.ID;
oMa开发者_如何学GoskedEditExtender.TargetControlID = txtMoney.ID;
oMaskedEditExtender.MaskType = MaskedEditType.Number;
oMaskedEditExtender.Mask = "9.999.999.999,99";
oMaskedEditExtender.InputDirection = MaskedEditInputDirection.RightToLeft;
Page.Controls.Add(oMaskedEditExtender);
please inform me if there is another solution for filtering the TextBox for only the french currency
The MaskedEditExtender
has a property called CultureName
. Quote from the documentation:
Name of culture to use (overrides the default page culture)
Didn't use it myself, but it definitely sounds like what you are looking for. Try to set it to "fr-FR"
and see what happens.
I forced it by using the backslach before the special characters like that:
oMaskedEditExtender.Mask = @"9.999.999.999\,99";
The best way to filter the output text is conclused in two points :-
1- myTextBox.Text = string.Format(System.Globalization.CultureInfo.GetCultureInfo("fr-FR"), "{0:c0}", _value);
Where, _value is a number with any format, then it will be formated in a french cyrrency format
2- Adding the MaskedEditExtender object with the next mask : MaskedEditExtender.Mask = @"9,999,999,999.99";
精彩评论