Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Replace /n with a XHTML <br /> using string.replace

Reply
Thread Tools

Replace /n with a XHTML <br /> using string.replace

 
 
Alun
Guest
Posts: n/a
 
      02-17-2008
I need to replace all new line characters in a string with a valid
XHTML line break tag <br />.

I'm trying to use the string.Replace method for this. Here's some
example code:

String description = "This is a video description \n Hello World";
description = description.Replace("\n", "<br />");
Literal1.Text = description;

When run the Literal controls rendered HTML is:

This is a video description <br> Hello World

I'm expecting it to be:

This is a video description <br /> Hello World

Many thanks
Alun
 
Reply With Quote
 
 
 
 
Masudur
Guest
Posts: n/a
 
      02-17-2008
On Feb 17, 10:53 am, Alun <alu...@gmail.com> wrote:
> I need to replace all new line characters in a string with a valid
> XHTML line break tag <br />.
>
> I'm trying to use the string.Replace method for this. Here's some
> example code:
>
> String description = "This is a video description \n Hello World";
> description = description.Replace("\n", "<br />");
> Literal1.Text = description;
>
> When run the Literal controls rendered HTML is:
>
> This is a video description <br> Hello World
>
> I'm expecting it to be:
>
> This is a video description <br /> Hello World
>
> Many thanks
> Alun


Hi...

try environment.newline in place of "<br/>"

Thanks
Masudur
www.munna.shatkotha.com
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      02-17-2008
On Feb 17, 5:53*am, Alun <alu...@gmail.com> wrote:
> I need to replace all new line characters in a string with a valid
> XHTML line break tag <br />.
>
> I'm trying to use the string.Replace method for this. *Here's some
> example code:
>
> String description = "This is a video description \n Hello World";
> description = description.Replace("\n", "<br />");
> Literal1.Text = description;
>
> When run the Literal controls rendered HTML is:
>
> This is a video description <br> Hello World
>
> I'm expecting it to be:
>
> This is a video description <br /> Hello World


For me it works. Do you parse the code again somewhere before it's
rendered?
 
Reply With Quote
 
Masudur
Guest
Posts: n/a
 
      02-18-2008
Hi...

I tested the your code... that is

"String description = "This is a video description \n Hello World";
description = description.Replace("\n", "<br />");
Literal1.Text = description; "

worked okay.,...

so need to use any environment.newline...

i think the problem is some where else... and i guess with html
encoding...

did you changed any thing on on redner or on prerender

Thanks
Masudur
www.munna.shatkotha.com

 
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
PSD to XHTML Conversion, PSD to HTML, Joomla, Drupal, WordpressConversion, PSD to XHTML CSS xhtml champs XML 0 08-02-2011 05:40 AM
PSD to XHTML Conversion, PSD to HTML, Joomla, Drupal, WordpressConversion, PSD to XHTML CSS xhtml champs C Programming 0 08-01-2011 06:29 AM
convert xhtml to another xhtml using xslt Usha2009 XML 0 12-20-2009 01:13 PM
Should I Convert Site To XHTML or XHTML mobile? chronos3d HTML 9 12-05-2006 04:46 PM
parse URL (href) from xhtml, xhtml -> text, for data hawat.thufir@gmail.com XML 7 02-08-2006 07:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57