468,283 Members | 1,788 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,283 developers. It's quick & easy.

Counting lines of text.

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
Nov 19 '05 #1
3 1205
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

"Brent" <""b b i g l e r "@ y a h o o ." wrote:
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

Nov 19 '05 #2
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

Nikander & Margriet Bruggeman wrote:
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

"Brent" <""b b i g l e r "@ y a h o o ." wrote:

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

Nov 19 '05 #3
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
"Brent" <""b b i g l e r "@ y a h o o ." wrote:
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

Nikander & Margriet Bruggeman wrote:
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

"Brent" <""b b i g l e r "@ y a h o o ." wrote:

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

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Derek Basch | last post: by
5 posts views Thread by Anders K. Jacobsen [DK] | last post: by
5 posts views Thread by andy.lee23 | last post: by
10 posts views Thread by cj | last post: by
7 posts views Thread by Mark..... | last post: by
6 posts views Thread by =?Utf-8?B?SGFucyAtIERpYUdyYXBoSVQgLQ==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.