meetpd
asked on
How to implement thousand seperator for text-boxes in ASP.NET C# (500 pt)
Hi,
For textboxes having amount values, I need a thousand seperator.
Eg. If we enter amount as '15000', it should change it to '15,000'.
Also, because I have more than 50 such textboxes, I need a way to implement this in one shot.
Appreciate your help!
For textboxes having amount values, I need a thousand seperator.
Eg. If we enter amount as '15000', it should change it to '15,000'.
Also, because I have more than 50 such textboxes, I need a way to implement this in one shot.
Appreciate your help!
ASKER
How can we apply this to all the textboxes?
two Solutions:
1> Implement a Ajax Mask Edit Extender (Out of the Box functionality) and attach it to ur text box ,a more professional approach as it will help u if tomorrow ur site switches for different language then ur Currency Format Will Change.
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx
2> A More easy approcah ,create a Custom Function to return a Number format
txtBox.text = ReturnFormat(NumToBeDispla yed);
string RetrunFormat(int Num)
{
return Num.ToString("N");
}
1> Implement a Ajax Mask Edit Extender (Out of the Box functionality) and attach it to ur text box ,a more professional approach as it will help u if tomorrow ur site switches for different language then ur Currency Format Will Change.
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx
2> A More easy approcah ,create a Custom Function to return a Number format
txtBox.text = ReturnFormat(NumToBeDispla
string RetrunFormat(int Num)
{
return Num.ToString("N");
}
txtBox.text = ReturnFormat(NumToBeDisplayed);
string RetrunFormat(int Num)
{
return Num.ToString("N");
}
ASKER
Hi DreamsTech,
I tried the solution that you gave. But it inserts two 0s after decimal.(e.g. 13,000.00) How can I remove those so that I get (e.g. 13,000) ?
Thanks!
I tried the solution that you gave. But it inserts two 0s after decimal.(e.g. 13,000.00) How can I remove those so that I get (e.g. 13,000) ?
Thanks!
ASKER
Also, I would want this to happen when the cursor is out of the textbox. How to do that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
value = 1234567890;
Console.WriteLine(value.To
// Displays 1,234,567,890