Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hard return in a string replace assitance 1

Status
Not open for further replies.

toetag

MIS
Sep 27, 2002
166
US
I'm using C# for code behinds in a ASP.NET site.

Users are entering information into a database and later display same. Some entries have hard returns in them and when it's redisplayed, the hard returns are of course not recognized and the formatting is thus wrong.

I need a way to replace the hard returns at display time with <br>. I have tried

DisplayString.Replace(char(13), &quot;<br>&quot;)
DisplayString.Replace(&quot;\r\n&quot;, &quot;<br>&quot;)

I of course know why the above didn't work, but i was swinging at a hope and a prayer.

Is there any way to use the Default &quot;String.Replace&quot; instead of having to dive into regex parsing?

Any assistance is greatly appreciated for this programming neophyte.
 
I believe that should work, but you need to assign the result:
[tt]DisplayString = DisplayString.Replace(&quot;\r\n&quot;, &quot;<br>&quot;)[/tt]
 
Thank you Rosenk! (you get a star)

Good lord that was too simple. ***WARNING: Old Cliche in use ***

if it'd been a snake...i'd of been bitten.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top