Petrus Theron
Petrus Theron

Reputation: 28807

  in String.Format(...) for currency

I use String.Format to do currency formatting. It works great, but I want a non-breaking space ( ) between the currency symbol (R) and the value so it doesn't wrap in small spaces, making it harder to read.

<%=String.Format("{0:R #,###.00;(R #,###.00);R 0.00}", Model)%>

where Model is a decimal.

How do I add &nbsp; between R and #,###.00 without confusing the String.Format method?

Upvotes: 0

Views: 4065

Answers (2)

Satya
Satya

Reputation: 4478

<%=String.Format("{0:R&nbsp;#,###.00;(R&nbsp;#,###.00);R&nbsp;0.00}", Model)%>

No?

Upvotes: 0

Wes P
Wes P

Reputation: 9840

Would it be possible to wrap the result in an element with the css white-space property set?

<span style="white-space:nowrap;"><%=String.Format("{0:R #,###.00;(R #,###.00);R 0.00}", Model)%></span>

Upvotes: 1

Related Questions