text/xml transformation format phone number

kyle shapiro asked on February 24, 2015 00:50

I want to format a 10digit number display like so:

Phone: (###) ###-####

I had a little asp.net snippet that worked great for this,

string.Format("{0:Phone: (###) ###-####}", Int64.Parse(Eval("OfficePhone").ToString()))

But "string.Format" is nonsense to XML transformation type. Any suggestions?

Correct Answer

Brenden Kehren answered on February 24, 2015 07:40

{% GetDocumentUrl(); %} // text/xml

Is not the same as

<%# GetDocumentUrl() %> // ascx or std c#

So if you'd wrap your code in <%# %> you'd be set.

<%# string.Format("{0:Phone: (###) ###-####}", Int64.Parse(Eval("OfficePhone").ToString())) %>
0 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on February 24, 2015 01:17

While you specified you created an asp.net snippet, that will not work in a text/xml transformation as you've found. Check out the Macro Methods documentation, should get you going in the right direction. Or just use ascx transformation, no reason not to.

0 votesVote for this answer Mark as a Correct answer

kyle shapiro answered on February 24, 2015 06:13

{% GetDocumentUrl(); %} would write "{% GetDocumentUrl(); %}" to my pages while using ascx. That's why I switched to text/xml transformation. Yes I have read the Macro Methods documentation.

0 votesVote for this answer Mark as a Correct answer

kyle shapiro answered on February 24, 2015 16:09

Ahh, it was such a simple solution. Thank you Brenden.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.