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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting in asp 1

Status
Not open for further replies.

yechi2001

MIS
Apr 5, 2005
24
US
I have a list of word documents containing various articles I have found and would like to post them on my website. Instead of creating a html page for each one I wanted to use asp. I am using access as my database program. When I copy and paste the text into a memo cell on access and then try to use live data on dreamweaver the formatting and pragraphing has gone. Can anyone out there tell me how to get the page to look the way I want it. Thanks
 
when you extract the info from the database, try this:
Code:
strText = Replace(objRS("MemoField"), vbcrlf, "<br />")

Response.Write strText
This will replace all the carriage returns with valid HTML line breaks.

Tony
_______________________________________________________________
 
I copied and pasted the script to various points on the html code but it doesnt seem to work. This may sound stupid but I just cannot figure out where to put it. Thanks
 
i like to use

tmpText = Replace(tmpText,Chr(13), "<br>" & vbCrlf)

but fester's is correct also
 
here is my script. as you can see I put it in the record set section. I think its the reference is the problem

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connArticle.asp" -->
<%
Dim rsArticles
Dim rsArticles_numRows

Set rsArticles = Server.CreateObject("ADODB.Recordset")
rsArticles.ActiveConnection = MM_connArticle_STRING
rsArticles.Source = "SELECT * FROM Articles"
rsArticles.CursorType = 0
rsArticles.CursorLocation = 2
rsArticles.LockType = 1
rsArticles.Open()

rsArticles_numRows = 0

strText = Replace(objRS("MemoField"), vbcrlf, "<br />")

Response.Write strText

%>

<html>

<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link >
</head>

<body>
<%=(rsArticles.Fields.Item("ArticleText").Value)%> </html>

<%
rsArticles.Close()
Set rsArticles = Nothing
%>
 
try this

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connArticle.asp" -->
<%
Dim rsArticles
Dim rsArticles_numRows

Set rsArticles = Server.CreateObject("ADODB.Recordset")
rsArticles.ActiveConnection = MM_connArticle_STRING
rsArticles.Source = "SELECT * FROM Articles"
rsArticles.CursorType = 0
rsArticles.CursorLocation = 2
rsArticles.LockType = 1
rsArticles.Open()

rsArticles_numRows = 0

strText = Replace(rsArticles("ArticleText"), vbcrlf, "<br />")

Response.Write strText

%>

<html>

<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link >
</head>

<body>
<%=strText%>
</body>
 </html>

<%
rsArticles.Close()
Set rsArticles = Nothing
%>
 
thanks you guys are great

It worked but let me ask you why can I not limit the size in a table. the text doesnt seem to wrap.

Thanks again I can sleep now
 
you can wrap the text by setting the width of the cell

ex.

<table>
<tr>
<td width="200">
<%=strText%>
</td>
</tr>
</table>
 
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connArticle.asp" -->

<%

Dim rsArticles
Dim rsArticles_numRows
Set rsArticles = Server.CreateObject("ADODB.Recordset")
rsArticles.ActiveConnection = MM_connArticle_STRING
rsArticles.Source = "SELECT * FROM Articles"
rsArticles.CursorType = 0
rsArticles.CursorLocation = 2
rsArticles.LockType = 1
rsArticles.Open()

rsArticles_numRows = 0
<%strText = Replace(rsArticles("ArticleText"), vbcrlf, "<br />")

Response.Write strText%>

%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link >
</head>
<body>
<table width="400" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#0000FF">
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td width="30" bgcolor="#0000FF">&nbsp;</td>
<td><%=(rsArticles.Fields.Item("ArticleText").Value)%></td>
<td width="30" bgcolor="#0000FF">&nbsp;</td>
</tr>
</table>
</body>
</html>
<%
rsArticles.Close()
Set rsArticles = Nothing

%>

Does anybody know why this code is showing the results outside the table?
 
try this

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/connArticle.asp" -->

<%

Dim rsArticles
Dim rsArticles_numRows
Set rsArticles = Server.CreateObject("ADODB.Recordset")
rsArticles.ActiveConnection = MM_connArticle_STRING
rsArticles.Source = "SELECT * FROM Articles"
rsArticles.CursorType = 0
rsArticles.CursorLocation = 2
rsArticles.LockType = 1
rsArticles.Open()

rsArticles_numRows = 0
strText = Replace(rsArticles("ArticleText"), vbcrlf, "<br />")

%>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link >
</head>
<body>
<table width="400" border="0" cellpadding="0" cellspacing="0">
  <tr bgcolor="#0000FF">
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr>
    <td width="30" bgcolor="#0000FF">&nbsp;</td>
    <td><%=strtext%></td>
    <td width="30" bgcolor="#0000FF">&nbsp;</td>
  </tr>
</table>
</body>
</html>
<%
rsArticles.Close()
Set rsArticles = Nothing

%>
 
So your telling me that I dont need to put
<%=(rsArticles.Fields.Item("ArticleText").Value)%>
in the <body> section of the htm script. Dreamweaver does that. You guys are amazing.
Thanks
 
yea, thts what we are telling you (just in case you were askin)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top