Reputation: 137
Have a relatively simple request.
I wish to pad left a string with spaces in an HTML page using VB on asp.net
For me the most obvious way to do it is
Response.Write(qty.PadLeft(5, " ") + " x " + part_number)
but as HTML does not render multiple spaces, this does not work
my workaround is
Response.Write(qty.PadLeft(5, "0") + " x " + part_number)
which pads the number with zero's but looks fairly unappealing on the website.
Any suggestions?
Thanks
Update: Based on replies so far I have tried
"100".PadLeft(5, " ")
but this outputs &&100
Upvotes: 0
Views: 1123
Reputation: 137
OK, I solved it by doing this
rep = string.concat(Enumerable.Repeat(" ", 5-qty.Length))
Response.Write(rep + qty+ " x " + part_number)
Not the best but works.
Upvotes: 1
Reputation: 12748
There's & nbsp; or setting or the css (with white-space) to see spaces. If you want to align information, you might want to also look at having a fixed font.
Upvotes: 0