Line feed in DB field

Discussion in 'ASP .Net' started by Frank Esser, Apr 14, 2005.

  1. Frank Esser

    Frank Esser Guest

    Hello,

    I read data from a DB field where a line feed ("\n") is in.
    I put this data as text to a label web control.
    In the HTML page the line feeds are shown as real line feeds in the HTML
    source.
    But in the label itself on the page in the browser the line feeds are
    ignored.

    How can I change the line feeds to HTML syntax (<br/>)?

    This does not work:
    Server.HtmlEncode(text)
    Frank Esser, Apr 14, 2005
    #1
    1. Advertising

  2. Frank Esser

    Brock Allen Guest

    You'll need to use String.Replace("\n", "<br/>")

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hello,
    >
    > I read data from a DB field where a line feed ("\n") is in.
    > I put this data as text to a label web control.
    > In the HTML page the line feeds are shown as real line feeds in the
    > HTML
    > source.
    > But in the label itself on the page in the browser the line feeds are
    > ignored.
    > How can I change the line feeds to HTML syntax (<br/>)?
    >
    > This does not work:
    > Server.HtmlEncode(text)
    Brock Allen, Apr 14, 2005
    #2
    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. Dave Tichenor
    Replies:
    3
    Views:
    32,125
    Steven Cheng[MSFT]
    Feb 17, 2004
  2. Sébastien de Mapias
    Replies:
    5
    Views:
    459
    Dave Miller
    May 26, 2009
  3. bernadou

    Force multi line field value to output with line breaks?

    bernadou, Jan 22, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    355
    bernadou
    Jan 23, 2006
  4. Sound
    Replies:
    2
    Views:
    436
    Randy Webb
    Sep 28, 2006
  5. jr
    Replies:
    3
    Views:
    414
Loading...

Share This Page