Displaying text in an asp.net table

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
 
P

Peter Rilling

You could replace all line breaks with a <br> so that he browser can handle
it.
 
G

Guest

Thanks for the reply, but how do I do that ?

The text that I want to display comes out of a table via a method in this
line...
tblAdvert.Rows(3).Cells(0).Text = advert.Description

Do I stick the <br>'s in as I save user's posting, and save the posting in
the database with the <br>'s, or do I add them in as I'm about to display the
posting. And what code do I use to go though the text (which could be in a
variable) and replace the line breaks with <br>'s ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top