By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,190 Members | 1,653 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,190 IT Pros & Developers. It's quick & easy.

Counting lines of text.

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.