Phone Number formatting in Textbox

5 posts, 0 answers
  1. Rekha
    Rekha avatar
    2 posts
    Member since:
    Jun 2009

    Posted 10 Jun 2009 Link to this post

    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.
  2. Sony Telkar
    Sony Telkar avatar
    14 posts
    Member since:
    Oct 2012

    Posted 10 Jun 2009 Link to this post

    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/

     

  3. Rekha
    Rekha avatar
    2 posts
    Member since:
    Jun 2009

    Posted 10 Jun 2009 Link to this post

    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.
  4. Chavdar
    Admin
    Chavdar avatar
    898 posts

    Posted 11 Jun 2009 Link to this post

    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.
  5. Penny
    Penny avatar
    1 posts
    Member since:
    Nov 2014

    Posted 25 Nov 2014 Link to this post

    I've had success with this:

    Format("{0:(###) ###-####}", CDbl(Fields.PrimaryContact.PhoneNumber)
Back to Top