Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Render text with line breaks

Reply
Thread Tools

Render text with line breaks

 
 
Lloyd Sheen
Guest
Posts: n/a
 
      09-22-2004
I have text which I need to render to a page. The text is stored in SQL
Server and contains CR/LF's. I need to display the text maintaining the
line breaks. What would be the best method to do this. I have tried labels
and replacing the CR/LF with a </br> but the resulting HTML does not contain
the </br> tags.

Lloyd Sheen


 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2NvdHQgU2ltb25z?=
Guest
Posts: n/a
 
      09-22-2004
First off, it's <br /> . Second off, you'll need to post some code.
 
Reply With Quote
 
 
 
 
Lloyd Sheen
Guest
Posts: n/a
 
      09-22-2004
Changing to <br/> did not help.

Protected WithEvents lblVendorText As System.Web.UI.WebControls.Label

Dim psTmp As String = Replace(poVI.VendorText, vbCrLf, "<br/>")
lblVendorText.Text = poVI.VendorText

During debugging I can see the <br/> tag in the psTmp variable but rendered
page shows no line breaks.

Lloyd Sheen
"Scott Simons" <Scott.Simons.At.MealMagic.Com.Remove.This> wrote in message
news:(E-Mail Removed)...
> First off, it's <br /> . Second off, you'll need to post some code.



 
Reply With Quote
 
Marina
Guest
Posts: n/a
 
      09-22-2004
Well, of course it's not working. You are assigning the label's text to
poVI.VendorText, instead of psTemp. So it's just displaying the original.

"Lloyd Sheen" <(E-Mail Removed)> wrote in message
news:Nii4d.3584$(E-Mail Removed) e.rogers.com...
> Changing to <br/> did not help.
>
> Protected WithEvents lblVendorText As System.Web.UI.WebControls.Label
>
> Dim psTmp As String = Replace(poVI.VendorText, vbCrLf, "<br/>")
> lblVendorText.Text = poVI.VendorText
>
> During debugging I can see the <br/> tag in the psTmp variable but

rendered
> page shows no line breaks.
>
> Lloyd Sheen
> "Scott Simons" <Scott.Simons.At.MealMagic.Com.Remove.This> wrote in

message
> news:(E-Mail Removed)...
> > First off, it's <br /> . Second off, you'll need to post some code.

>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      09-22-2004
Your second theory is correct - you need to replace all CRLFs with <br>
tags. If it isn't working, you're llooking for the wrong character(s). Try
using Environment.NewLine for the character to replace.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Lloyd Sheen" <(E-Mail Removed)> wrote in message
news:bPh4d.41502$(E-Mail Removed) ble.rogers.com...
> I have text which I need to render to a page. The text is stored in SQL
> Server and contains CR/LF's. I need to display the text maintaining the
> line breaks. What would be the best method to do this. I have tried

labels
> and replacing the CR/LF with a </br> but the resulting HTML does not

contain
> the </br> tags.
>
> Lloyd Sheen
>
>



 
Reply With Quote
 
Lloyd Sheen
Guest
Posts: n/a
 
      09-22-2004
Thanks, takes someone else to see the simple things.

Lloyd Sheen

"Marina" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Well, of course it's not working. You are assigning the label's text to
> poVI.VendorText, instead of psTemp. So it's just displaying the original.
>
> "Lloyd Sheen" <(E-Mail Removed)> wrote in
> message
> news:Nii4d.3584$(E-Mail Removed) e.rogers.com...
>> Changing to <br/> did not help.
>>
>> Protected WithEvents lblVendorText As System.Web.UI.WebControls.Label
>>
>> Dim psTmp As String = Replace(poVI.VendorText, vbCrLf, "<br/>")
>> lblVendorText.Text = poVI.VendorText
>>
>> During debugging I can see the <br/> tag in the psTmp variable but

> rendered
>> page shows no line breaks.
>>
>> Lloyd Sheen
>> "Scott Simons" <Scott.Simons.At.MealMagic.Com.Remove.This> wrote in

> message
>> news:(E-Mail Removed)...
>> > First off, it's <br /> . Second off, you'll need to post some code.

>>
>>

>
>



 
Reply With Quote
 
=?Utf-8?B?SmVyZW15IERhdmlz?=
Guest
Posts: n/a
 
      09-22-2004
Just because it's fun to give bad advice:
You could always blast the text directly into a <pre> tag, or (better) use a
css style with "whitespace: pre;" on the element you put the text into. This
is probably far dirtier than the <br> replacement, but it can be workable if
you're lazy like me.

"Lloyd Sheen" wrote:

> I have text which I need to render to a page. The text is stored in SQL
> Server and contains CR/LF's. I need to display the text maintaining the
> line breaks. What would be the best method to do this. I have tried labels
> and replacing the CR/LF with a </br> but the resulting HTML does not contain
> the </br> tags.
>
> Lloyd Sheen
>
>
>

 
Reply With Quote
 
=?Utf-8?B?SmVyZW15IERhdmlz?=
Guest
Posts: n/a
 
      09-22-2004
Correction: the css style rule is "white-spacere;" with the hyphen.

"Jeremy Davis" wrote:

> Just because it's fun to give bad advice:
> You could always blast the text directly into a <pre> tag, or (better) use a
> css style with "whitespace: pre;" on the element you put the text into. This
> is probably far dirtier than the <br> replacement, but it can be workable if
> you're lazy like me.
>
> "Lloyd Sheen" wrote:
>
> > I have text which I need to render to a page. The text is stored in SQL
> > Server and contains CR/LF's. I need to display the text maintaining the
> > line breaks. What would be the best method to do this. I have tried labels
> > and replacing the CR/LF with a </br> but the resulting HTML does not contain
> > the </br> tags.
> >
> > Lloyd Sheen
> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing rails render method outside of view / Decorating render Glenn Gillen Ruby 0 11-17-2006 02:30 PM
Beginner: read $array with line breaks line by line Marek Stepanek Perl Misc 12 09-02-2006 10:27 AM
Force multi line field value to output with line breaks? bernadou ASP .Net Web Controls 2 01-23-2006 01:23 PM
Text with automated line-breaks for a picture Herbert Gerstinger HTML 26 08-09-2005 05:53 PM
Page.Render do not render complete page Lau Lei Cheong ASP .Net 1 05-15-2004 04:10 AM



Advertisments