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

Phone Number formatting in Textbox

5 Answers 1336 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rekha
Top achievements
Rank 1
Rekha asked on 10 Jun 2009, 04:29 PM
When I try to set formatting to (###) ###-#### for a textbox, it still returns an unformatted string.

I would appreciate it, if you could let me know how I can set the formatting for telephone number in the report textbox.

5 Answers, 1 is accepted

Sort by
0
Sony Telkar
Top achievements
Rank 1
answered on 10 Jun 2009, 05:00 PM

I guess this should solve your problem.
String.Format(”{0:(###) ###-####}”, 18005551212);

 

Also you can visit this link. It could be helpful.
http://blog.stevex.net/index.php/string-formatting-in-csharp/

 

0
Rekha
Top achievements
Rank 1
answered on 10 Jun 2009, 05:45 PM
Thanks for the reply Sony. When I try to set the fomat property like you suggested, it returns the unformatted string. Also in the Value type my options are either numeric or date time. I am dealing with a string in a field called Phone and when I set the property to string.format("{0: (###) ###-####}",fields.Phone), I get my setting returned verbatim.
0
Chavdar
Telerik team
answered on 11 Jun 2009, 03:08 PM
Hi Rekha,

Custom numeric formats are applicable only for numeric data so you cannot use them to format a string. To achieve the expected result you can use a user defined function and format the value with the help of the string methods.

Greetings,
Chavdar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Penny
Top achievements
Rank 1
answered on 25 Nov 2014, 03:18 PM
I've had success with this:

Format("{0:(###) ###-####}", CDbl(Fields.PrimaryContact.PhoneNumber)
0
dave
Top achievements
Rank 1
Iron
answered on 12 May 2023, 03:05 PM
In the format field, select custom format, enter: (000) 000-0000
In the value field, enter CDbl(Fields.PhoneNumber)
Tags
General Discussions
Asked by
Rekha
Top achievements
Rank 1
Answers by
Sony Telkar
Top achievements
Rank 1
Rekha
Top achievements
Rank 1
Chavdar
Telerik team
Penny
Top achievements
Rank 1
dave
Top achievements
Rank 1
Iron
Share this question
or