类型:转载 责任编辑:asp.net 日期:2007/05/23
热门软件下载:
我写了一个ASP页面做新闻系统,数据库是Access,新闻内容是备注类型。可我读取出来的是没有段落的,尽管写入的时候是有格式的,有什么快捷的办法解决吗?代码如下:(我这里用replace把空格换成了段落标记,但没有空格怎么办?)
<%
Sql=""
Sql="select title,content,times from news where id="&id
Rs.open Sql,Conn,1,1
content=rs(1)
%>
<center>
<p> <%=Rs("title")%></p>
</center>
<p align="right"><font size="2"><%=Rs("times")%></font></p>
<p><Br> <%=Rs("content")%><p>
<font size="3"><p><%content=replace(content," ","</p><p>")
response.Write(content)%></p> </font>
网友回答:
<pre>content</pre>
<textarea><%=Rs("content")%></textarea>
<%= replace(replace(replace(replace(Rs("content"),"<","<"),">",">")," "," "),chr(13),"<br>")%>
<textarea name="" cols="10" rows="55" readonly="readonly" wrap="virtual"><%=objrs("body")%></textarea>
<pre>content</pre>
<%= replace(Rs("content"),chr(13)&chr(10),"<br> ")%>
<%= replace(Rs("content"),vbcrlf,"<br>")%>
同上,呵呵
给你两段,我自己写的,可是相换的。
function displaystr(str)
str=RTrim(str)
if not isnull(str) then
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = Replace(str, CHR(32), " ")
str = Replace(str, CHR(9), " ")
str = Replace(str, " ", " ")
str = Replace(str, CHR(34), """)
str = Replace(str, CHR(39), "'")
str = Replace(str, vbCr, "")
str = Replace(str, vbLf, "<BR>")
str = Replace(str, vbCrLf, "<BR>")
str = replace(str,"-","−")
displaystr = str
else
displaystr="---"
end if
end function
function displaystr1(str)
str=RTrim(str)
if not isnull(str) then
str = replace(str, ">", ">")
str = replace(str, "<", "<")
str = Replace(str, " ", CHR(32))
str = Replace(str, " ", CHR(9))
str = Replace(str, " ", " ")
str = Replace(str, "%20", CHR(34))
str = Replace(str, "'", CHR(39))
str = Replace(str, "", vbCr)
str = Replace(str, "<BR>", vbLf)
str = Replace(str, "<BR>", vbCrLf)
str = replace(str,"−","-")
displaystr1 = str
else
displaystr1="---"
end if
end function
有些你不想转的就平掉,然后调用就好了。