What's wrong withe the statement below???:

Nov 18, 2010 at 12:41 AM
Edited Nov 18, 2010 at 12:49 AM

 

What is wrong with the following statement:

(<%: String.Format("{0:(###) ###-####}", model.ContactPhone ) %>)



Every example I have seent shows this String.Format to be a valid format for phone numbers, yet when I use this in the "Details.aspx" view I get an unformatted result? What am I doing wrong.

If this is the wrong place for this type of question, please direct me to someone or URL that can provide an answer.

Thanks in advance . . .

TomJ 



Jan 2, 2011 at 9:56 PM

This would work only if the model.ContactPhone is a long.  It won't work if ContactPhone is a string. If contact phone is a string, break it into substrings and  use the format string  "({0}) {1}-{2}"