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?
Re: Inserting new line into ASP label control?
Try this
VB Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = crlfToBr(DatabaseText)
End Sub
Private Sub crlfToBr(ByVal strValue As String)
strValue = Replace(strValue, Chr(13) & Chr(10), "<br>")
End Sub
Re: Inserting new line into ASP label control?
I'm guessing that second sub should be a function...
But ya it works well, Thanks :)