|
 |
asp_web_howto thread: Printing CFLF within document
Message #1 by "Neal Lebar" <nlebar@i...> on Wed, 31 Jan 2001 02:33:55 -0000
|
|
I have a SQL db that contains a text type of field. In that field is stored press releases. The press
releases contain single ' and double " quotes. At entry I fix the string to allow for the quotes. However, the press release is
formatted with carriage returns and line feeds.. but when I print the field to the screen, it eliminates all the carriage returns
and line feeds.
I thought the way to handle this would be to print one character at a time from the press release field while checking for chr(10)
and chr(13). If I came accross either of these characters, I'd do a response.write "<BR><BR>".
I'm confused with how to reference values that I read in a recordset. I thought I could simply say txtDetail = objRS("Detail").
Then I could use txtDetail for things like if len(txtDetail) then...
I'm also confused as to why the field doesn't retain the CFLF.
Here's the code...
'Set the SQL string
strSQL = "Select * from PressMaster Where ID = '" & _
Request.Form("cboPress") & "'"
'Open the recordset getting the club details for this club
objRS.Open strSQL,"dsn=Teledata_db"
<tr>
<td bgcolor="#FFFFFF" width="70%"><font face="Verdana" size="2">
<%
if len(objrs("Summary")) >< 0 then
for i = 0 to len(objrs("Summary")) -1
if mid(objrs("Summary"),i,1) <> chr(13) and
mid(objrs "Summary"),i,1) <> chr(10) then
Response.Write (mid(objrs("Summary"),i,1))
else
Response.Write "<BR><BR>"
end if
next
end if
%>
</td>
</tr>
Message #2 by "Wally Burfine" <oopconsultant@h...> on Wed, 31 Jan 2001 04:15:37 -0000
|
|
You should use the replace function. The way you are doing it must take 2/N
seconds to run where n is almost zero.
Response.Write Replace(objrs("Summary"),vbcrlf,"<br><br>")
Also, the mid function uses a base of 1 rather than zero.
>From: "Neal Lebar" <nlebar@i...>
>Reply-To: "ASP Web HowTo" <asp_web_howto@p...>
>To: "ASP Web HowTo" <asp_web_howto@p...>
>Subject: [asp_web_howto] Printing CFLF within document
>Date: Wed, 31 Jan 2001 02:33:55 -0000
>
>I have a SQL db that contains a text type of field. In that field is stored
>press releases. The press releases contain single ' and double " quotes.
>At entry I fix the string to allow for the quotes. However, the press
>release is formatted with carriage returns and line feeds.. but when I
>print the field to the screen, it eliminates all the carriage returns and
>line feeds.
>
>I thought the way to handle this would be to print one character at a time
>from the press release field while checking for chr(10) and chr(13). If I
>came accross either of these characters, I'd do a response.write
>"<BR><BR>".
>
>I'm confused with how to reference values that I read in a recordset. I
>thought I could simply say txtDetail = objRS("Detail"). Then I could use
>txtDetail for things like if len(txtDetail) then...
>
>I'm also confused as to why the field doesn't retain the CFLF.
>
>Here's the code...
>
>'Set the SQL string
> strSQL = "Select * from PressMaster Where ID = '" & _
> Request.Form("cboPress") & "'"
>
>'Open the recordset getting the club details for this club
> objRS.Open strSQL,"dsn=Teledata_db"
>
>
><tr>
> <td bgcolor="#FFFFFF" width="70%"><font face="Verdana" size="2">
>
> <%
>
> if len(objrs("Summary")) >< 0 then
>
> for i = 0 to len(objrs("Summary")) -1
>
> if mid(objrs("Summary"),i,1) <> chr(13) and
> mid(objrs "Summary"),i,1) <> chr(10) then
>
> Response.Write (mid(objrs("Summary"),i,1))
>
> else
>
> Response.Write "<BR><BR>"
>
> end if
>
> next
>
> end if
>
> %>
>
> </td>
> </tr>
>
Message #3 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Wed, 31 Jan 2001 09:43:15 -0000
|
|
before actually saving the text, use the "replace" function to replace
vbCrLf with <BR>
If you are using a SQL text field, retreive the value using the "getChunk"
method in ADO.
when creating your query, you also need to put text fields at the end of
your list of fields (not sure if this is still the case in SQL7 though)
-----Original Message-----
From: Neal Lebar [mailto:nlebar@i...]
Sent: Wednesday, January 31, 2001 2:34 AM
To: ASP Web HowTo
Subject: [asp_web_howto] Printing CFLF within document
I have a SQL db that contains a text type of field. In that field is stored
press releases. The press releases contain single ' and double " quotes.
At entry I fix the string to allow for the quotes. However, the press
release is formatted with carriage returns and line feeds.. but when I print
the field to the screen, it eliminates all the carriage returns and line
feeds.
I thought the way to handle this would be to print one character at a time
from the press release field while checking for chr(10) and chr(13). If I
came accross either of these characters, I'd do a response.write "<BR><BR>".
I'm confused with how to reference values that I read in a recordset. I
thought I could simply say txtDetail = objRS("Detail"). Then I could use
txtDetail for things like if len(txtDetail) then...
I'm also confused as to why the field doesn't retain the CFLF.
Here's the code...
'Set the SQL string
strSQL = "Select * from PressMaster Where ID = '" & _
Request.Form("cboPress") & "'"
'Open the recordset getting the club details for this club
objRS.Open strSQL,"dsn=Teledata_db"
<tr>
<td bgcolor="#FFFFFF" width="70%"><font face="Verdana" size="2">
<%
if len(objrs("Summary")) >< 0 then
for i = 0 to len(objrs("Summary")) -1
if mid(objrs("Summary"),i,1) <> chr(13) and
mid(objrs "Summary"),i,1) <> chr(10) then
Response.Write (mid(objrs("Summary"),i,1))
else
Response.Write "<BR><BR>"
end if
next
end if
%>
</td>
</tr>
Message #4 by "Neal Lebar" <nlebar@i...> on Wed, 31 Jan 2001 15:25:16 -0000
|
|
Thanks... it worked like a champ.
Message #5 by "Whitmore, Todd x78046" <WhitmorT@b...> on Wed, 31 Jan 2001 13:21:22 -0500
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C08BB3.233A6DD4
Content-Type: text/plain;
charset="iso-8859-1"
don't you want to replace a CR/LF pair with a single <br> ???
-----Original Message-----
From: Wally Burfine [mailto:oopconsultant@h...]
Sent: Tuesday, January 30, 2001 11:16 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: Printing CFLF within document
You should use the replace function. The way you are doing it must take 2/N
seconds to run where n is almost zero.
Response.Write Replace(objrs("Summary"),vbcrlf,"<br><br>")
Also, the mid function uses a base of 1 rather than zero.
>From: "Neal Lebar" <nlebar@i...>
>Reply-To: "ASP Web HowTo" <asp_web_howto@p...>
>To: "ASP Web HowTo" <asp_web_howto@p...>
>Subject: [asp_web_howto] Printing CFLF within document
>Date: Wed, 31 Jan 2001 02:33:55 -0000
>
>I have a SQL db that contains a text type of field. In that field is stored
>press releases. The press releases contain single ' and double " quotes.
>At entry I fix the string to allow for the quotes. However, the press
>release is formatted with carriage returns and line feeds.. but when I
>print the field to the screen, it eliminates all the carriage returns and
>line feeds.
>
>I thought the way to handle this would be to print one character at a time
>from the press release field while checking for chr(10) and chr(13). If I
>came accross either of these characters, I'd do a response.write
>"<BR><BR>".
>
>I'm confused with how to reference values that I read in a recordset. I
>thought I could simply say txtDetail = objRS("Detail"). Then I could use
>txtDetail for things like if len(txtDetail) then...
>
>I'm also confused as to why the field doesn't retain the CFLF.
>
>Here's the code...
>
>'Set the SQL string
> strSQL = "Select * from PressMaster Where ID = '" & _
> Request.Form("cboPress") & "'"
>
>'Open the recordset getting the club details for this club
> objRS.Open strSQL,"dsn=Teledata_db"
>
>
><tr>
> <td bgcolor="#FFFFFF" width="70%"><font face="Verdana" size="2">
>
> <%
>
> if len(objrs("Summary")) >< 0 then
>
> for i = 0 to len(objrs("Summary")) -1
>
> if mid(objrs("Summary"),i,1) <> chr(13) and
> mid(objrs "Summary"),i,1) <> chr(10) then
>
> Response.Write (mid(objrs("Summary"),i,1))
>
> else
>
> Response.Write "<BR><BR>"
>
> end if
>
> next
>
> end if
>
> %>
>
> </td>
> </tr>
>
---
MaximumASP offers enhanced hosting solutions on the Windows 2000 platform.
Dedicated processor, RAM, and server resources provide dedicated server
performance at virtual server prices. Commercial components provided; custom
components allowed.
$subst('Email.Unsub')
|
|
 |