CRLF ..

Discussion in 'ASP .Net' started by Jim in Arizona, Aug 24, 2005.

  1. 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
     
    Jim in Arizona, Aug 24, 2005
    #1
    1. Advertising

  2. Hey Jim &vbCrlf this is &vbCrlf how!

    Looks like:

    Hey Jim
    this is
    how!
     
    Sparky Arbuckle, Aug 24, 2005
    #2
    1. Advertising

  3. "Sparky Arbuckle" <> wrote in message
    news:...
    > 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
     
    Jim in Arizona, Aug 24, 2005
    #3
  4. 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" <> wrote in message
    news:%...
    > "Sparky Arbuckle" <> wrote in message
    > news:...
    >> 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
    >
    >
    >
     
    Kevin Spencer, Aug 24, 2005
    #4
  5. "Kevin Spencer" <> wrote in message
    news:...
    > 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!
     
    Jim in Arizona, Aug 24, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry III

    Re: how to check CRLF in C#

    Jerry III, Aug 25, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    807
    Jerry III
    Aug 25, 2003
  2. Kevin Spencer

    Re: how to check CRLF in C#

    Kevin Spencer, Aug 25, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    27,949
    Jerry III
    Aug 27, 2003
  3. Simon Chung-Jen Chuang

    Re: how to check CRLF in C#

    Simon Chung-Jen Chuang, Aug 26, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    419
    Simon Chung-Jen Chuang
    Aug 26, 2003
  4. Jack Wright

    Problem in CRLF in multiline fields

    Jack Wright, Apr 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    395
    Jack Wright
    Apr 21, 2004
  5. Michael Persaud

    CRLF How does it work for asp.net???!!

    Michael Persaud, May 27, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    5,922
    Michael Persaud
    May 27, 2004
Loading...

Share This Page