Counting lines of text.

Discussion in 'ASP .Net' started by Brent, Feb 16, 2005.

  1. Brent

    Brent Guest

    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
     
    Brent, Feb 16, 2005
    #1
    1. Advertising

  2. 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
    >
     
    =?Utf-8?B?TmlrYW5kZXIgJiBNYXJncmlldCBCcnVnZ2VtYW4=, Feb 17, 2005
    #2
    1. Advertising

  3. Brent

    Brent Guest

    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
    >>
     
    Brent, Feb 17, 2005
    #3
  4. 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
    > >>

    >
     
    =?Utf-8?B?TmlrYW5kZXIgJiBNYXJncmlldCBCcnVnZ2VtYW4=, Feb 18, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    322
    Chris Theis
    Dec 14, 2005
  2. Murali
    Replies:
    2
    Views:
    605
    Jerry Coffin
    Mar 9, 2006
  3. tolkien

    counting lines in text file

    tolkien, Oct 12, 2007, in forum: C Programming
    Replies:
    7
    Views:
    388
    user923005
    Oct 12, 2007
  4. André Freitas

    reading and counting lines in a text file

    André Freitas, Jul 31, 2009, in forum: ASP .Net
    Replies:
    3
    Views:
    460
    André Freitas
    Aug 2, 2009
  5. edwardfredriks

    counting up instead of counting down

    edwardfredriks, Sep 6, 2005, in forum: Javascript
    Replies:
    6
    Views:
    222
    Dr John Stockton
    Sep 7, 2005
Loading...

Share This Page