473,670 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

preserving carriage returns

Hi,

I have some data which is stored in my MySQL database as TEXT. when the
data is entered in, it has some carriage returns in it, and this can be
seen when querying the data using MySQL Query Browser.

I want to then display this text within <p> tags when requested from
the database. However, the test is formatted without the carriage
returns.

Is there a simple bit of code in which i can use to display the text
complete with its carriage returns, or do i have to have a bit of messy
code which will replace all the carriage returns with &vbCrLF; ?

Nov 19 '05 #1
8 2218
You need to replace the CR's with <P> or <BR> 's in order to translate them
to HTML actionable code tags.

Use a RegEx to do this.

Regards Mr Newbie.
"TheDude5B" <ti*******@gmai l.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
Hi,

I have some data which is stored in my MySQL database as TEXT. when the
data is entered in, it has some carriage returns in it, and this can be
seen when querying the data using MySQL Query Browser.

I want to then display this text within <p> tags when requested from
the database. However, the test is formatted without the carriage
returns.

Is there a simple bit of code in which i can use to display the text
complete with its carriage returns, or do i have to have a bit of messy
code which will replace all the carriage returns with &vbCrLF; ?

Nov 19 '05 #2
I would think you would have to replace the carriage returns with <br>'s.

Dim TestString As String = "Shopping List"
' Returns "Shipping List".
Dim aString As String = Replace(TestStr ing, "o", "i")

Greg

"TheDude5B" <ti*******@gmai l.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.com...
Hi,

I have some data which is stored in my MySQL database as TEXT. when the
data is entered in, it has some carriage returns in it, and this can be
seen when querying the data using MySQL Query Browser.

I want to then display this text within <p> tags when requested from
the database. However, the test is formatted without the carriage
returns.

Is there a simple bit of code in which i can use to display the text
complete with its carriage returns, or do i have to have a bit of messy
code which will replace all the carriage returns with &vbCrLF; ?

Nov 19 '05 #3
I have used
Replace(post.Te xt, vbCrLf, "<br />")

and everything is working now, however, this is good for displaying my
text within the <p> tags. but when i view the text within a textbox,
for example when i want to edit the text, it shows up the <br /> tags

Nov 19 '05 #4
Only do the replace when displaying the text in a label. Should give some
thought to using Server.HtmlEnco de too.

Replace(Server. HtmlEncode(post .Text), vbCrLf, "<br />")

"TheDude5B" <ti*******@gmai l.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
I have used
Replace(post.Te xt, vbCrLf, "<br />")

and everything is working now, however, this is good for displaying my
text within the <p> tags. but when i view the text within a textbox,
for example when i want to edit the text, it shows up the <br /> tags

Nov 19 '05 #5
ok i will not replace the vbcrlf when adding it to the database.
however i am unsure as to apply the replace code with my asp:repeater
controls.

i have the code for the line, which i am wanting to use the replace in,
as

<td colspan="2"
class="bordersi des"><p><%#Cont ainer.DataItem( "post_text" )%></p></td>

how would i apply Replace( ,vbCrLf,"<br />") with this line
of code?

Nov 19 '05 #6
i have got it now thanks.

used the code

<%#( DataBinder.Eval (Container.Data Item, "post_text")).R eplace(vbCrLf,
"<br/>")%>

and this has worked.

Thanks for your Help Greg

Nov 19 '05 #7
Another method would be to write a protected helper function in your code
behind.

something like this:

<%# MyHelperFunctio n(DataBinder.Ev al(Container.Da taItem, "post_text")))% >

Protected Function MyHelperFunctio n(ByVal value As Object) As String
If value Is DBNull.Value Then
Return ""
Else
Return value.ToString. Replace(vbCrLf, "<br/>")
End If
End Function

I find this kind of code necessary to protected myself from NULL values
coming back from db.

Greg

"TheDude5B" <ti*******@gmai l.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
i have got it now thanks.

used the code

<%#( DataBinder.Eval (Container.Data Item, "post_text")).R eplace(vbCrLf,
"<br/>")%>

and this has worked.

Thanks for your Help Greg

Nov 19 '05 #8
Instead of doing a replace, a css attribute exists that you can use to
format the text automatically:

<div style="white-space: pre-line;">
Text goes here
</div>

Lookup the "white-space" css attribute for more info.

Best of luck,
Matt Furnari

Nov 19 '05 #9

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

Similar topics

4
7315
by: Les Juby | last post by:
Can someone please help with a suggestion as to how I can keep the formatting (carriage returns) that the user enters into a memo field and then display that later. I figured I might be able to use: 'replace carriage returns with BRs comment=Replace(comment, chr(13), "<br>") but obviously net.! The <pre> tag doesn't sem to help either as the embedded return is
2
2945
by: eagleofjade | last post by:
I am trying to import data from a Word document into an Access table with VBA. The Word document is a form which has various fields. One of the fields is a field for notes. In some cases, this note field contains carriage returns. When I import a note field that has carriage returns, what shows up in the Access field are vertical black lines where the carriage return should be.
12
5609
by: Nimmy | last post by:
Hi, I have a data file and I want to remove Carriage returns. Any one has any C code/program which does this? I am working on Windows XP machine.....I don't have access to UNIX machine. But I need to send this data file to the Unix machine once I remove the carriage retunrns from my XP machine. Thanks
2
2332
by: Matt Mercer | last post by:
Hi all, I am having a frustration problem, and I have read about 25 newsgroup postings that do not have a satisfying answer :) The problem appears to be common where carriage returns are lost when pulling data from an SQL database. The thing that frustrates me the most, is that when I use Enterprise Manager, the carriage returns ARE THERE. It looks fine until I pull it out.
7
11187
by: mattrapoport | last post by:
I have a page with a div on it. The div displays a user comment. When the user logs into this page, their current comment is pulled from a db and displayed in the div. The user can edit the comment through a pop-up that contains a textarea. When the user hits OK on the pop-up, the text in the textarea is sent to a function on the main page. The function inserts the text into the div's text node. Please don't ask why I'm making this...
2
4648
by: GregBeagle | last post by:
Windows XP I have a simple form from which I want to generate an email with the contents of the form. I use carriage returns to format the content for readability. When I test it on my computer the email generated by getURL("mailto..") is fine in my email client. Carriage returns are kept etc and shows how I want it. However when I upload it to the server and run it on the web, the carriage returns are stripped out of the text and all...
0
1459
by: markus.shure | last post by:
Hi, I'm noticed a problem testing a JAX-WS client with a WSE server. The JAX-WS client adds carriage returns to a SOAP header element that is signed. This causes the WSE server to raise an error: "The signature or decryption failed". If the carriage returns are removed, the same web service call is successful. I tried replicating the situation with a WSE client. I created a WSE client that adds a SOAP header element that contains a...
11
12591
by: evenlater | last post by:
My db allows the user to send email via CDO. The body of the email is determined in code. I have built an email form with To, CC and Subject lines and a large text box for the body of the message so the user can edit the default email message body before sending the message. But when I populate the large text box (txtBody), I can't get it to include the carriage returns. I've tried vbNewLine, vbCrLf, Chr(10) and Chr(13). I've got the...
1
10699
by: jollyroger | last post by:
I have searched the web forums, and can't seem to find an answer to this particular problem I have. In an excel sheet, cells in one column have formatted text in the "wrapped" cells. For many of the cells it is far more than 256 char. After import to Access, the carriage return (CR) and Line Feed (LF) is shown with a square symbol in the text, and the text is just "dumped" into the field without CR or LF. Have also tried to indentify the...
0
8907
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8817
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8593
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7423
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6218
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5687
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2804
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1799
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.