Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line feeds when using ASP's to read an access database 1

Status
Not open for further replies.

hallm

Programmer
Jun 11, 2000
159
US
I'm using the following ASP command to write from my database to the net:<br><br>response.write(news(&quot;longstory&quot;))<br><br>How can I format that command so the story will have the proper linefeeds.&nbsp;&nbsp;In perl you basically replace CR's with BR's.&nbsp;&nbsp;How do you do it in ASP
 
What does it do now? <br>Jam everything together? <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
It jams everything together.&nbsp;&nbsp;When I put blank lines in the database it returns the straight text without the extra lines.
 
Dear hallm,<br><br>&gt; When I put blank lines in the database it returns the straight text without the extra lines.<br><br>That is probably not what is happening. To find out put the contents from your database column back into an HTML 'textarea' element and you will probably see all the blank lines are still there. The reason they don't show up inside of a table cell or a paragraph element is that HTML standard calls for linefeeds to be ignored in rendering. So... you need process the data into the HTML display that you desire. I usually start with a paragraph tag then replace all the double linefeed characters with an end paragraph and a paragraph tag then write the data then the final end paragraph tag.<br><br>Something like this:<br>myData = recset(&quot;data&quot;);<br>re = new RegExp(&quot;\n\n&quot;, &quot;g&quot;);<br>myData = myData.replace(re, &quot;&lt;/p&gt;&lt;p&gt;&quot;);<br>Response.write( &quot;&lt;p&gt;&quot; + myData + &quot;&lt;/p&gt;&quot;);<br><br>Hope this helps<br>-pete
 
If you include the adovbs.inc file, you can use the VB constant &quot;vbcrlf&quot; (visual basic carriage return line feed) to create new lines.
 
well I didnt even include the adovbs.inc , i just use vbcrlf, and vbtab without any include files placed in an include tag on my page. just so&nbsp;&nbsp;you know, it works without it. some of the constants dont however. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
why kill yourself formatting what comes out of a database for your HTML page?&nbsp;&nbsp;Use this function I wrote, it'll handle it for you:<br><br>&lt;%<br>Function PrepForHtml (strDirty)<br> Dim strClean<br> If IsNull(strDirty) OR Trim(strDirty) = &quot;&quot; Then<br> PrepForHTML = &quot;&quot;<br> Exit Function<br> End If<br> strClean = Trim(strDirty)<br> strClean = Replace(strClean, &quot;&lt;&quot;, &quot;&lt;&quot;, 1, -1 , 1)<br> strClean = Replace(strClean, &quot;&gt;&quot;, &quot;&gt;&quot;, 1, -1 , 1)<br> strClean = Replace(strClean, Chr(10), &quot;&lt;br&gt;&quot;, 1, -1, 1)<br> PrepForHtml = strClean<br>End Function<br>%&gt;<br><br>How to use?<br><br>&lt;%<br>Dim sText<br>sText = PrepForHTML(Rs.Fields(&quot;myField&quot;).Value)<br>%&gt;<br><br>viola!&nbsp;&nbsp;You can be assured your data will come out clean and pretty.
 
Thank you very much.&nbsp;&nbsp;Your comments have been very helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top