Display string with whitespace in ASP.NET?
I need to display a string which has a white space on a asp.net page.
*Here is what I am doing:*
cell = New TableCell cell.Text = value (lets assume value is <" test with whitespace "> row.Cells.Add(cell)
and it gets rendered as
<tr> <td>" test with whitespace "</td> </tr>
whitespaces within single quotes are not displayed.
I want this value to be displayed as it is on my page.
HTML strips out all but one space character. You need to use the &NBSP; entity to ensure white space is presented with HTML. Use the String class's Replace method (or RegEx) to swap out each space for &NBSP;