I'm having an issue formatting a simple string in Razor, I've verified that the syntax is correct in regular C# code, but once I migrate it to my HTML page using Razor and String.Format doesn't seem to work. I'm trying to format a phone number string from ########## to (###)###-#### so my code for this is
@{
string number = contact.ContactNumber;
string formattedNumber = String.Format("({0}){1}-{2}", number.Substring(0, 3), number.Substring(3, 3), number.Substring(6, 4));
}
I'm trying to verify if this is correct just by doing alert(@formattedNumber) but it doesn't appear to be working, the alert won't even appear. However if my code is simply
@{
string number = contact.ContactNumber;
string formattedNumber = String.Format("{0}{1}{2}", number.Substring(0, 3), number.Substring(3, 3), number.Substring(6, 4));
}
Note that this one should just display the regular number, and the alert will work correctly and display ##########
Any suggestions on why the (###)###-#### isn't working?