Display string with spaces in ASP.NET?

I need to display a string with a space in an asp.net page.

**** That's what I'm doing: ****

cell = New TableCell

cell.Text = value  (lets assume value is <"  test with whitespace    ">

row.Cells.Add(cell)

      

and it displays as

<tr>
<td>"  test with whitespace    "</td>
</tr>

      

spaces in single quotes are not displayed.

I want this value to be displayed as it is on my page.

+1


source to share


2 answers


HTML highlights all but one character. You need to use an object to ensure the whitespace is represented by HTML. Use the replace method of the String (or RegEx) class to replace each place for NBP;



http://en.wikipedia.org/wiki/Non-breaking_space

+3


source


Maybe you are trying to get space before and after your text to get the spacing between the table cell border and your text?

If so, you should take a look at the CSS style " addition " or padding-left, padding-right. This will add space between the border of the tables and your text.

Add this to your page:



<style type="text/css">
td {
padding: 4px;
}
</style>

      

If this is not what you want, I am sorry.

+1


source







All Articles