This is a migrated thread and some comments may be shown as answers.

How to get formatted text from RadNumericTextbox

4 Answers 153 Views
Input
This is a migrated thread and some comments may be shown as answers.
Michal Siudyka
Top achievements
Rank 2
Michal Siudyka asked on 08 Jun 2010, 03:30 PM
Hi,

I have created a RadNumericTextbox control and set the NumberFormat's properties. Everything is displayed correctly, but how can I get programmatically the formatted text.

i.e.

A control displays: $ 1,223.34

in code:

string value = control.Text;

and the value equals 1223.34 and I want to get $ 1,223.34

Thanks in advance

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Jun 2010, 07:38 AM
Hi Michal,

I am not sure about any property available for retrieving the exact formatted value from RadNumericTextBox.

But you can accomplish same by using following code.
 
  double v = Convert.ToDouble(RadNumericTextBox1.Value);  
  string valueFormatted = String.Format("${0}", v.ToString("#,#.##", CultureInfo.InvariantCulture)); 


Hope this helps,
Princy.
0
Michal Siudyka
Top achievements
Rank 2
answered on 09 Jun 2010, 09:27 PM
I thought so that should be formatted manually, thanks.
0
Accepted
Daniel
Telerik team
answered on 11 Jun 2010, 03:06 PM
Hello Michal,

It is possible to get the formatted value. Here is how:
string formattedValue = Telerik.Web.UI.NumberFormat.Format(RadNumericTextBox1.Value, RadNumericTextBox1.NumberFormat);

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Michal Siudyka
Top achievements
Rank 2
answered on 11 Jun 2010, 03:33 PM
Great, thanks a lot.
Tags
Input
Asked by
Michal Siudyka
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Michal Siudyka
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or