473,327 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Store Carriage Returns as <br /><br /> or <p></p> in DB

I have a multi line text in an admin page on my cms.

I am trying to capture carriage returns as and replace them with
<p></p> bfore the string gets written to the database.

I have tried all the charcontrols option and chr(13) with success.. was
using the following code:

Dim s As String = MyTextbox.Text

s = "<p>" & s & "</p>"
s.Replace(ControlChars.CrLf & ControlChars.CrLf, "</p><p>")
s.Replace(ControlChars.Lf, "<br />")
s.Replace("\n", "<br />")
s.Replace(ControlChars.Cr & ControlChars.Cr, "</p><p>")
s.Replace(ControlChars.NewLine, "<br />")
s.Replace(ControlChars.VerticalTab, "<br />")
s.Replace(Chr(13), "<br />")

I have tried all the above, but non have worked.

The only work around i have found is to perform a string.replace when
displaying on the webpage by the following:

<%# container.dataitem("MyTextField").replace(chr(13), "<br />") %>

This works but is not ideal as it means i have to hard code each page.

How do i do this?

Nov 21 '05 #1
1 3139
Hi,

String.Replace is a function that returns a string. Try this
instead.

s=s.Replace(ControlChars.CrLf & ControlChars.CrLf, "</p><p>")
Ken
-------------------
"Winshent" <wi*************@yahoo.co.uk> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I have a multi line text in an admin page on my cms.

I am trying to capture carriage returns as and replace them with
<p></p> bfore the string gets written to the database.

I have tried all the charcontrols option and chr(13) with success.. was
using the following code:

Dim s As String = MyTextbox.Text

s = "<p>" & s & "</p>"
s.Replace(ControlChars.CrLf & ControlChars.CrLf, "</p><p>")
s.Replace(ControlChars.Lf, "<br />")
s.Replace("\n", "<br />")
s.Replace(ControlChars.Cr & ControlChars.Cr, "</p><p>")
s.Replace(ControlChars.NewLine, "<br />")
s.Replace(ControlChars.VerticalTab, "<br />")
s.Replace(Chr(13), "<br />")

I have tried all the above, but non have worked.

The only work around i have found is to perform a string.replace when
displaying on the webpage by the following:

<%# container.dataitem("MyTextField").replace(chr(13), "<br />") %>

This works but is not ideal as it means i have to hard code each page.

How do i do this?

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: fis | last post by:
Hi all, I've problem because there are needed break lines in my texts on the web site but i can't do it :( My pipeline looks like: XMS -> I18N -> XSLT -> HTML I have lot of texts in my...
6
by: Lasse | last post by:
I have done this simple function, it seems to work as intended, to solve a problem i have had for a while. I couldnt find any sample around that was working for me. I would like to test it with...
12
by: thomas_jedenfelt_1 | last post by:
Hi everyone, Is the W3C HTML Validator in error when it returns <br /> as valid for HTML 4.01 Strict doctype? In March 2004 , the Validator returned <br />, <hr /> and <img /> as invalid for...
7
by: noor.rahman | last post by:
I have an XML file that stores data from an HTML form. I use XSL to display the data in HTML format. The data may have newline characters. However, XSL is not displaying the newlines properly in...
2
by: Winshent | last post by:
I have a multi line text in an admin page on my cms. I am trying to capture carriage returns as and replace them with <p></p> bfore the string gets written to the database. I have tried all...
13
by: CK | last post by:
Hi all, I have a textarea control. I am putting it's value in an html email. The problem is that the new lines are being ignored. I want to take the controls value and replace any newline...
9
by: Wayne | last post by:
$a = $_POST; # txt_content = This is a<CR><LF>Test $p = str_replace ("%0D%0A", "<br>", $a); That is the above code that I am using, however, it is not picking up the CR/LF from the textarea. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.