multiple lines in a label

Discussion in 'ASP .Net' started by tshad, Jan 12, 2005.

  1. tshad

    tshad Guest

    I have a textbox that I am storing as text (or as a varChar). The field has
    multiple lines in it (not wrapped).

    When I read it back into a multiline textbox, it works fine. But when I
    read it back into a label, it shows all lines together.

    Is there a way to get the Label to display the lines separately?

    I could use textbox and get rid of the border and set enable to false, but
    then it greys the text, which I don't want.

    Thanks,

    Tom.
    tshad, Jan 12, 2005
    #1
    1. Advertising

  2. Tom,
    Remember, line-breaks from a text box or text area are not the same
    thing as an HTML line break. Basically you'll need to replace the linefeed
    characters in the text box with the HTML <br>. This is a fairly
    straightforward operation using the Replace() method of the string
    functionality in .Net, such as
    varChar.ToString().Replace(Environment.NewLine,"<br>")

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP- FrontPage

    "tshad" <> wrote in message
    news:OQB39eO%...
    >I have a textbox that I am storing as text (or as a varChar). The field
    >has multiple lines in it (not wrapped).
    >
    > When I read it back into a multiline textbox, it works fine. But when I
    > read it back into a label, it shows all lines together.
    >
    > Is there a way to get the Label to display the lines separately?
    >
    > I could use textbox and get rid of the border and set enable to false, but
    > then it greys the text, which I don't want.
    >
    > Thanks,
    >
    > Tom.
    >
    Mark Fitzpatrick, Jan 12, 2005
    #2
    1. Advertising

  3. tshad

    tshad Guest

    "Mark Fitzpatrick" <> wrote in message
    news:u2B6KjO%...
    > Tom,
    > Remember, line-breaks from a text box or text area are not the same
    > thing as an HTML line break. Basically you'll need to replace the linefeed
    > characters in the text box with the HTML <br>. This is a fairly
    > straightforward operation using the Replace() method of the string
    > functionality in .Net, such as
    > varChar.ToString().Replace(Environment.NewLine,"<br>")


    Does this replace all Newlines?

    Also, do I need to move the data to string or can I do it directly from
    either my label control or data coming from my dataset, such as:

    if not (ClientReader("achievements") is DBNull.Value) then
    achievements.text = ClientReader("achievements")
    achievements.ToString().replace(environment.newline,"<br>") ->
    doesn't seem to work here
    end if

    or can I do it directly in the ClientReader line above?

    Thanks,

    Tom.

    >
    > Hope this helps,
    > Mark Fitzpatrick
    > Microsoft MVP- FrontPage
    >
    > "tshad" <> wrote in message
    > news:OQB39eO%...
    >>I have a textbox that I am storing as text (or as a varChar). The field
    >>has multiple lines in it (not wrapped).
    >>
    >> When I read it back into a multiline textbox, it works fine. But when I
    >> read it back into a label, it shows all lines together.
    >>
    >> Is there a way to get the Label to display the lines separately?
    >>
    >> I could use textbox and get rid of the border and set enable to false,
    >> but then it greys the text, which I don't want.
    >>
    >> Thanks,
    >>
    >> Tom.
    >>

    >
    >
    tshad, Jan 12, 2005
    #3
  4. tshad

    tshad Guest

    "MWells" <outbound__at_sygnal.com> wrote in message
    news:ebu%231kP%...
    > if not (ClientReader("achievements") is DBNull.Value) then
    > achievements.text =
    > ClientReader("achievements").ToString().replace(environment.newline,"<br>")
    > end if
    >
    > -or-
    >
    > if not (ClientReader("achievements") is DBNull.Value) then
    > achievements.text = ClientReader("achievements")
    > achievements.text =
    > achievements.text.ToString().replace(environment.newline,"<br>")
    > end if
    >


    Thanks - that really helps,

    Tom
    >
    >
    > "tshad" <> wrote in message
    > news:eRPirDP#...
    >> "Mark Fitzpatrick" <> wrote in message
    >> news:u2B6KjO%...
    >> > Tom,
    >> > Remember, line-breaks from a text box or text area are not the

    > same
    >> > thing as an HTML line break. Basically you'll need to replace the

    > linefeed
    >> > characters in the text box with the HTML <br>. This is a fairly
    >> > straightforward operation using the Replace() method of the string
    >> > functionality in .Net, such as
    >> > varChar.ToString().Replace(Environment.NewLine,"<br>")

    >>
    >> Does this replace all Newlines?
    >>
    >> Also, do I need to move the data to string or can I do it directly from
    >> either my label control or data coming from my dataset, such as:
    >>
    >> if not (ClientReader("achievements") is DBNull.Value) then
    >> achievements.text = ClientReader("achievements")
    >> achievements.ToString().replace(environment.newline,"<br>") ->
    >> doesn't seem to work here
    >> end if
    >>
    >> or can I do it directly in the ClientReader line above?
    >>
    >> Thanks,
    >>
    >> Tom.
    >>
    >> >
    >> > Hope this helps,
    >> > Mark Fitzpatrick
    >> > Microsoft MVP- FrontPage
    >> >
    >> > "tshad" <> wrote in message
    >> > news:OQB39eO%...
    >> >>I have a textbox that I am storing as text (or as a varChar). The
    >> >>field
    >> >>has multiple lines in it (not wrapped).
    >> >>
    >> >> When I read it back into a multiline textbox, it works fine. But when

    > I
    >> >> read it back into a label, it shows all lines together.
    >> >>
    >> >> Is there a way to get the Label to display the lines separately?
    >> >>
    >> >> I could use textbox and get rid of the border and set enable to false,
    >> >> but then it greys the text, which I don't want.
    >> >>
    >> >> Thanks,
    >> >>
    >> >> Tom.
    >> >>
    >> >
    >> >

    >>
    >>

    >
    >
    tshad, Jan 12, 2005
    #4
  5. tshad

    MWells Guest

    if not (ClientReader("achievements") is DBNull.Value) then
    achievements.text =
    ClientReader("achievements").ToString().replace(environment.newline,"<br>")
    end if

    -or-

    if not (ClientReader("achievements") is DBNull.Value) then
    achievements.text = ClientReader("achievements")
    achievements.text =
    achievements.text.ToString().replace(environment.newline,"<br>")
    end if



    "tshad" <> wrote in message
    news:eRPirDP#...
    > "Mark Fitzpatrick" <> wrote in message
    > news:u2B6KjO%...
    > > Tom,
    > > Remember, line-breaks from a text box or text area are not the

    same
    > > thing as an HTML line break. Basically you'll need to replace the

    linefeed
    > > characters in the text box with the HTML <br>. This is a fairly
    > > straightforward operation using the Replace() method of the string
    > > functionality in .Net, such as
    > > varChar.ToString().Replace(Environment.NewLine,"<br>")

    >
    > Does this replace all Newlines?
    >
    > Also, do I need to move the data to string or can I do it directly from
    > either my label control or data coming from my dataset, such as:
    >
    > if not (ClientReader("achievements") is DBNull.Value) then
    > achievements.text = ClientReader("achievements")
    > achievements.ToString().replace(environment.newline,"<br>") ->
    > doesn't seem to work here
    > end if
    >
    > or can I do it directly in the ClientReader line above?
    >
    > Thanks,
    >
    > Tom.
    >
    > >
    > > Hope this helps,
    > > Mark Fitzpatrick
    > > Microsoft MVP- FrontPage
    > >
    > > "tshad" <> wrote in message
    > > news:OQB39eO%...
    > >>I have a textbox that I am storing as text (or as a varChar). The field
    > >>has multiple lines in it (not wrapped).
    > >>
    > >> When I read it back into a multiline textbox, it works fine. But when

    I
    > >> read it back into a label, it shows all lines together.
    > >>
    > >> Is there a way to get the Label to display the lines separately?
    > >>
    > >> I could use textbox and get rid of the border and set enable to false,
    > >> but then it greys the text, which I don't want.
    > >>
    > >> Thanks,
    > >>
    > >> Tom.
    > >>

    > >
    > >

    >
    >
    MWells, Jan 12, 2005
    #5
  6. tshad

    Divya

    Joined:
    Jan 14, 2010
    Messages:
    1
    Hi
    It helps me alot
    Thanks
    Divya, Jan 14, 2010
    #6
    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. Shapper
    Replies:
    2
    Views:
    721
    Scott Mitchell [MVP]
    May 7, 2005
  2. Josef K.

    <label><div></div></label> allowed?

    Josef K., May 20, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    13,300
    Josef K.
    May 22, 2005
  3. Praveen
    Replies:
    1
    Views:
    944
    Rob Williscroft
    Nov 5, 2006
  4. Cah Sableng
    Replies:
    0
    Views:
    230
    Cah Sableng
    Apr 23, 2007
  5. Knut Krueger
    Replies:
    8
    Views:
    253
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page