Displaying text in an asp.net table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using an asp.net table to display postings in a classifieds website.

This is a section of the HTM I am using...

<asp:table id="tblAdvert" Width="466px" Height="78px" runat="server"
BackColor="Gainsboro" BorderStyle="Solid" BorderWidth="1px"
BorderColor="MidnightBlue" GridLines="Both" CellSpacing="0">
<asp:TableRow>
<asp:TableCell></asp:TableCell>
</asp:TableRow>
...
<asp:TableRow>

And then I fill the table like this (in the code-behind) ...
tblAdvert.Rows(3).Cells(0).Text = advert.Description

The problem is that the text all gets displayed in one paragraph, even
though the user

might have added lines when they entered the posting.

So I tried this...
tblAdvert.Rows(3).Cells(0).Text = "<pre class=advertdescription>" &
advert.Description &

"</pre>"

This expands the table so that it stretches out, and the user has to scroll
horizontally

to see the whole posting.

Any suggestions ? Thanks,
Craig
 
I think, but I'm not an ASP/HTML programmer really that you need to replace
the new line char (chr(13)) in your text to a break row in HTML (<br>????)

Hope it sparks an idea.
Chris
 
Craig said:
I am using an asp.net table to display postings in a classifieds website.

This is a section of the HTM I am using...

<asp:table id="tblAdvert" Width="466px" Height="78px" runat="server"
BackColor="Gainsboro" BorderStyle="Solid" BorderWidth="1px"
BorderColor="MidnightBlue" GridLines="Both" CellSpacing="0">
<asp:TableRow>
<asp:TableCell></asp:TableCell>
</asp:TableRow>
...
<asp:TableRow>

And then I fill the table like this (in the code-behind) ...
tblAdvert.Rows(3).Cells(0).Text = advert.Description

The problem is that the text all gets displayed in one paragraph, even
though the user

might have added lines when they entered the posting.

So I tried this...
tblAdvert.Rows(3).Cells(0).Text = "<pre class=advertdescription>" &
advert.Description &

"</pre>"

This expands the table so that it stretches out, and the user has to
scroll horizontally

to see the whole posting.

Any suggestions ? Thanks,
Craig
Any characters such as line feeds, carriage returns, tabs, end of page, are
ignored. They are called whitespace in the Web. Will not display except
within a <pre> element.
 
Back
Top