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

Nov 17, 2010 at 11:41 PM
Edited Nov 17, 2010 at 11:49 PM


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 . . .


Jan 2, 2011 at 8: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}"