Counting lines of text.

B

Brent

Say that I have a text box that holds 5 lines of text. If the user
enters ten text lines, I want the first four lines of text displayed,
followed by a "More" hyperlink. The link will pop up another page to
display the rest of the text.

The problem is that I don't know how to count lines. I can count
characters, but this solution fails spectacularly when it encounters the
characters "<br/>" (which should be counted as a full line, of course).

Anyone have an idea how to solve the problem? Any resources I can look up?

Thanks for any help.

--Brent
 
G

Guest

Maybe it helps if you establish what a line of text is, in your case. Is a
line something which is always ended by <br> or <p>, or does a newline count
as well (which could be checked using the Environment.NewLine property).

Kind regards,
Nikander & Margriet Bruggeman
 
B

Brent

Good point. Hmmm ... I think for my purposes a line of text would be n
characters, or any of "<br>", "<p>", or like HTML. Mainly, I just want
to keep text fully inside a <div> with a fixed height and width. An
example of the problem is here:

http://www.thsalumni.com/Alumni.aspx?ID=2699

The information in the "Latest News" <div> extends beyond the box.

Thanks for any help.

--Brent
 
G

Guest

Looks like this websites uses a very practical solution. It just seems to
count the number of characters and the text stops at that point. Maybe this
is workable for you too.

Kind regards,
Nikander & Margriet Bruggeman
 

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

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top