Results 1 to 3 of 3

Thread: Inserting new line into ASP label control? [Resolved]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2004
    Location
    Cape Town, South Africa
    Posts
    149

    Inserting new line into ASP label control? [Resolved]

    I'm wondering how I should go about this. I've searched on google for a bit but didnt find much.

    I've got an asp:label control on my form which gets its contents from a sql db. The user can write this contents to the sql db in an asp:textbox (TextMode="MultiLine").

    I'm wondering now how I can format this content so that each new line the user makes (by pressing enter) will show up as a new line in the asp:label. At the moment the contents is compressed so that it does not pick up the paragraphs, and just displays as one long paragraph.

    What I am talking about is much like this forum. You can format your paragraphs nicely and it displays exactly how you have written it.

    Can you even do this in asp controls? Will I need to rather look at writing html to the page?
    Last edited by Patch21; Jan 18th, 2005 at 10:22 AM.

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861

    Re: Inserting new line into ASP label control?

    Try this
    VB Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.    Label1.Text = crlfToBr(DatabaseText)
    3. End Sub
    4.  
    5. Private Sub crlfToBr(ByVal strValue As String)
    6.    strValue = Replace(strValue, Chr(13) & Chr(10), "<br>")
    7. End Sub
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2004
    Location
    Cape Town, South Africa
    Posts
    149

    Re: Inserting new line into ASP label control?

    I'm guessing that second sub should be a function...

    But ya it works well, Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width