473,396 Members | 1,861 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,396 software developers and data experts.

CRLF ..

When I write code to show the text from a database that was posted from a
textbox, no carriage returns show up. If I load the text back into a text
box, the original carriage returns are there.

The way I'm writing the text to a webpage is via HTML. I use a <div
id="htmltext" runat=server> then do a htmltext.InnerHTML = strResultsHolder.
I don't know how I would tell HTML to insert a <br> or <p> where the
carriage return/line feed should be. I like the control I have when writing
to the page as an HTML stream. Is there a better way?

TIA,
Jim
Nov 19 '05 #1
4 1454
Hey Jim &vbCrlf this is &vbCrlf how!

Looks like:

Hey Jim
this is
how!

Nov 19 '05 #2
"Sparky Arbuckle" <tw*@secureroot.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hey Jim &vbCrlf this is &vbCrlf how!

Looks like:

Hey Jim
this is
how!


I understand the vbCrLf syntax and have used it in VB6 and VB.NET.

My problem has to do with putting the propery paragraphs in HTML from vb.
I'll give you a coding exampe:

------------------------------------------------------------------------

Protected Sub btnTransfer_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnTransfer.Click

Dim strConnection, strSQLTransfer, strSQL, strSQLNote, strResults,
strSQLRemove, txtID As String
Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim objDataReader As OleDbDataReader

txtISNotes.Text = Replace(txtISNotes.Text, "'", "''")

txtID = txtTransfer.Text

strResults = ""

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"e:\hhsinternal\cterrorlog\ctprob.mdb"

strSQL = "SELECT ID, ClientID, Field, Form, Employee, username," & _
" ip, probdt, Descript, isnotes, noshow FROM TProblem" & _
" WHERE ((TProblem.noshow)= NO) ORDER BY ID DESC;"

strSQLTransfer = "INSERT INTO TClaimTrak (ID, ClientID, Form, Field,
Descript, "
strSQLTransfer += "Employee, username, isnotes) "
strSQLTransfer += "SELECT TProblem.ID, TProblem.ClientID,
TProblem.Form, TProblem.Field, "
strSQLTransfer += "Tproblem.Descript, TProblem.Employee,
Tproblem.username, TProblem.isnotes "
strSQLTransfer += "FROM TProblem "
strSQLTransfer += "WHERE TProblem.ID=" & txtID & ";"

strSQLNote = "UPDATE TProblem"
strSQLNote += " Set isnotes = '" & txtISNotes.Text & "'"
strSQLNote += " WHERE id = " & txtID & ";"

strSQLRemove = "UPDATE TProblem"
strSQLRemove += " Set noshow = True"
strSQLRemove += " WHERE id = " & txtTransfer.Text & ";"
objConnection = New OleDbConnection(strConnection)
objConnection.Open()

If Not txtISNotes.Text = "" Then
objCommand = New OleDbCommand(strSQLNote, objConnection)
objCommand.ExecuteNonQuery()
End If

objCommand = New OleDbCommand(strSQLTransfer, objConnection)
objCommand.ExecuteNonQuery()

objCommand = New OleDbCommand(strSQLRemove, objConnection)
objCommand.ExecuteNonQuery()

objCommand = New OleDbCommand(strSQL, objConnection)
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = True
strResults += "<table cellpadding=""5"" cellspacing=""0""
border=""1"" bordercolor=""maroon"" width=""90%""><tr>"
strResults += "<td bgcolor=""red"" width=""10%""><b>ID:<br
/><font color=""white"">" & objDataReader("ID").ToString &
"</font></b></td>"
strResults += "<td bgcolor=""silver"" width=""30%""><b>Client
ID:</b><br />" & objDataReader("ClientID").ToString & "</td>"
strResults += "<td bgcolor=""silver""
width=""30%""><b>Field:</b><br />" & objDataReader("Field").ToString &
"</td>"
strResults += "<td bgcolor=""silver""
width=""30%""><b>Form:</b><br />" & objDataReader("Form").ToString & "</td>"

strResults += "</tr><tr>"

strResults += "<td bgcolor=""silver"" width=""10%""><b>Employee
Name:<br /><font color=""navy"">" & objDataReader("Employee").ToString &
"</font></b></td>"
strResults += "<td bgcolor=""silver""
width=""30%""><b>Username:</b><br />" & objDataReader("username").ToString &
"</td>"
strResults += "<td bgcolor=""silver"" width=""30%""><b>IP
Address:</b><br />" & objDataReader("ip").ToString & "</td>"
strResults += "<td bgcolor=""silver""
width=""30%""><b>Date/Time:</b><br />" & objDataReader("probdt").ToString &
"</td>"

strResults += "</tr><tr>"

strResults += "<td colspan=""4""><b>Description:</b><br />" &
objDataReader("Descript").ToString & "</td>"
strResults += "</tr><tr>"
strResults += "<td colspan=""4""><b>HHS Info Systems
Notes:</b><br />" & objDataReader("isnotes").ToString & "<br /></td>"
strResults += "</tr></table>"
strResults += "<br />"
Loop

objDataReader.Close()
objConnection.Close()

report.InnerHtml = strResults
txtTransfer.Text = ""
txtISNotes.Text = ""
End Sub

------------------------------------------------------------------------

I copied and pasted that from one of the pages I'm referring to. What
happens is when someone types into a textbox and clicks the button, that
text is placed into a memo field in an Access database. Then, that note is
redrawn to the browser with HTML. If the person had pressed the ENTER button
a few times and began a new paragraph in the text box, that new paragraph
will not show up when the note is rewritten to the browser. There is only a
single space instead of new blank lines. If they click another button that
loads the note back into a textbox, the text that they typed is in its
original format, with the blank lines. So, it looks like the database is
keeping the original format, but the HTML stream is not writing those extra
lines.

So, how do I get around this?

Thanks,
Jim

Nov 19 '05 #3
Dim s As String = "some string with line breaks in it"

txtISNotes.Text = s.Replace(VbCrLf, "<br>")

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Paranoia is just a state of mind.

"Jim in Arizona" <ti*******@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Sparky Arbuckle" <tw*@secureroot.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hey Jim &vbCrlf this is &vbCrlf how!

Looks like:

Hey Jim
this is
how!


I understand the vbCrLf syntax and have used it in VB6 and VB.NET.

My problem has to do with putting the propery paragraphs in HTML from vb.
I'll give you a coding exampe:

------------------------------------------------------------------------

Protected Sub btnTransfer_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnTransfer.Click

Dim strConnection, strSQLTransfer, strSQL, strSQLNote, strResults,
strSQLRemove, txtID As String
Dim objConnection As OleDbConnection
Dim objCommand As OleDbCommand
Dim objDataReader As OleDbDataReader

txtISNotes.Text = Replace(txtISNotes.Text, "'", "''")

txtID = txtTransfer.Text

strResults = ""

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
"e:\hhsinternal\cterrorlog\ctprob.mdb"

strSQL = "SELECT ID, ClientID, Field, Form, Employee, username," &
_
" ip, probdt, Descript, isnotes, noshow FROM TProblem" & _
" WHERE ((TProblem.noshow)= NO) ORDER BY ID DESC;"

strSQLTransfer = "INSERT INTO TClaimTrak (ID, ClientID, Form,
Field, Descript, "
strSQLTransfer += "Employee, username, isnotes) "
strSQLTransfer += "SELECT TProblem.ID, TProblem.ClientID,
TProblem.Form, TProblem.Field, "
strSQLTransfer += "Tproblem.Descript, TProblem.Employee,
Tproblem.username, TProblem.isnotes "
strSQLTransfer += "FROM TProblem "
strSQLTransfer += "WHERE TProblem.ID=" & txtID & ";"

strSQLNote = "UPDATE TProblem"
strSQLNote += " Set isnotes = '" & txtISNotes.Text & "'"
strSQLNote += " WHERE id = " & txtID & ";"

strSQLRemove = "UPDATE TProblem"
strSQLRemove += " Set noshow = True"
strSQLRemove += " WHERE id = " & txtTransfer.Text & ";"
objConnection = New OleDbConnection(strConnection)
objConnection.Open()

If Not txtISNotes.Text = "" Then
objCommand = New OleDbCommand(strSQLNote, objConnection)
objCommand.ExecuteNonQuery()
End If

objCommand = New OleDbCommand(strSQLTransfer, objConnection)
objCommand.ExecuteNonQuery()

objCommand = New OleDbCommand(strSQLRemove, objConnection)
objCommand.ExecuteNonQuery()

objCommand = New OleDbCommand(strSQL, objConnection)
objDataReader = objCommand.ExecuteReader()

Do While objDataReader.Read() = True
strResults += "<table cellpadding=""5"" cellspacing=""0""
border=""1"" bordercolor=""maroon"" width=""90%""><tr>"
strResults += "<td bgcolor=""red"" width=""10%""><b>ID:<br
/><font color=""white"">" & objDataReader("ID").ToString &
"</font></b></td>"
strResults += "<td bgcolor=""silver"" width=""30%""><b>Client
ID:</b><br />" & objDataReader("ClientID").ToString & "</td>"
strResults += "<td bgcolor=""silver""
width=""30%""><b>Field:</b><br />" & objDataReader("Field").ToString &
"</td>"
strResults += "<td bgcolor=""silver""
width=""30%""><b>Form:</b><br />" & objDataReader("Form").ToString &
"</td>"

strResults += "</tr><tr>"

strResults += "<td bgcolor=""silver"" width=""10%""><b>Employee
Name:<br /><font color=""navy"">" & objDataReader("Employee").ToString &
"</font></b></td>"
strResults += "<td bgcolor=""silver""
width=""30%""><b>Username:</b><br />" & objDataReader("username").ToString
& "</td>"
strResults += "<td bgcolor=""silver"" width=""30%""><b>IP
Address:</b><br />" & objDataReader("ip").ToString & "</td>"
strResults += "<td bgcolor=""silver""
width=""30%""><b>Date/Time:</b><br />" & objDataReader("probdt").ToString
& "</td>"

strResults += "</tr><tr>"

strResults += "<td colspan=""4""><b>Description:</b><br />" &
objDataReader("Descript").ToString & "</td>"
strResults += "</tr><tr>"
strResults += "<td colspan=""4""><b>HHS Info Systems
Notes:</b><br />" & objDataReader("isnotes").ToString & "<br /></td>"
strResults += "</tr></table>"
strResults += "<br />"
Loop

objDataReader.Close()
objConnection.Close()

report.InnerHtml = strResults
txtTransfer.Text = ""
txtISNotes.Text = ""
End Sub

------------------------------------------------------------------------

I copied and pasted that from one of the pages I'm referring to. What
happens is when someone types into a textbox and clicks the button, that
text is placed into a memo field in an Access database. Then, that note is
redrawn to the browser with HTML. If the person had pressed the ENTER
button a few times and began a new paragraph in the text box, that new
paragraph will not show up when the note is rewritten to the browser.
There is only a single space instead of new blank lines. If they click
another button that loads the note back into a textbox, the text that they
typed is in its original format, with the blank lines. So, it looks like
the database is keeping the original format, but the HTML stream is not
writing those extra lines.

So, how do I get around this?

Thanks,
Jim

Nov 19 '05 #4

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Ow*************@TK2MSFTNGP09.phx.gbl...
Dim s As String = "some string with line breaks in it"

txtISNotes.Text = s.Replace(VbCrLf, "<br>")

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Paranoia is just a state of mind.


Excellent!! Thanks Kevin!
Nov 19 '05 #5

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

Similar topics

12
by: eddie wang | last post by:
What is CRLF? Thanks. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
4
by: McKirahan | last post by:
How would I use a regular expression to remove all trailing Carriage Returns and Line Feeds (%0D%0A) from a textarea's value? Thanks in advance. Also, are they any great references for learning...
5
by: McKirahan | last post by:
I'd like to use regular expressions to remove extraneous Carriage Return Line Feeds (CrLf) from a textarea before the form is submitted. I'd like to remove all trailing CrLf's and convert all...
3
by: Jon | last post by:
Hi... I'm getting stumped over the something that MUST be simple...basically, I'm trying to replace the characters 0D0A with a crlf, using Regex.Replace(). The problem is, the replaced string...
1
by: Jack Wright | last post by:
Dear All, In a multiline field if I enter the following way: Mangesh Anant Kodilkar There is a carriage return after each word. Now when I press save,it loses the CRLF characters. This is not...
2
by: Michael Persaud | last post by:
Hi All, Im trying to have a few strings presented in a LABEL. However the CRLF is not working. eg str = str1 + crlf + str2 + crlf + str3 label.text= str Do i need to declare the crlf as a...
2
by: Andrew | last post by:
Hello. I am working with very large files in my .NET project (1 million plus records). Some of these files do not have crlf's, which makes it very hard to read the file without a layout or record...
0
by: Tomas | last post by:
When I use a __doPostBack to submit a page to the server the last textbox on the page always contains a CRLF. I've used HttpRequest.SaveAs to dump the entire request (IIS 6) to disk and the body of...
8
by: kerberoz | last post by:
whats the equivalent following ControlChars.Lf, ControlChars.Cr, ControlChars.CrLf code in vb.net
9
by: amyl | last post by:
I have an application that is reading data from text files to the first occurrence of a double crlf. I have this working using streamreader and using readline. However, I am hitting 500+ files...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...

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.