资讯   |   开发   |   选机中心   |   产品大全 | IBM | 惠普 | 联想 | 戴尔 | 苹果 | 神舟
更多: | 华硕 | 明基 | 方正 | 紫光 | TCL | 夏新 | 联宝 | 宏碁 | 七喜 | 长城 | 清华同方 | 海尔 | 三星 | 东芝 | 索尼 | 富士通 | LG | 技术 | ddnoon
当前位置:笔记本 > 软件开发 >
Advertisement
文章正文

100分求教!怎样格式化从数据库中备注字段里的文本?读出来的不分段啊!

类型:转载   责任编辑: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>&nbsp;&nbsp;&nbsp;<%=Rs("content")%><p>  
            <font   size="3"><p><%content=replace(content,"   ","</p><p>")  
    response.Write(content)%></p>   </font>

网友回答:

发表者:mouse_2004

<pre>content</pre>

发表者:wch0410

<textarea><%=Rs("content")%></textarea>

发表者:devilzone

<%=   replace(replace(replace(replace(Rs("content"),"<","&lt"),">","&gt"),"   ","&nbsp;"),chr(13),"<br>")%>

发表者:davery

<textarea   name=""   cols="10"   rows="55"   readonly="readonly"   wrap="virtual"><%=objrs("body")%></textarea>  
   
   
  <pre>content</pre>  
 

发表者:bluemoon0001

<%=   replace(Rs("content"),chr(13)&chr(10),"<br>&nbsp;&nbsp;&nbsp;&nbsp;")%>

发表者:l3300

<%=   replace(Rs("content"),vbcrlf,"<br>")%>  
 

发表者:IQ250

同上,呵呵

发表者:dreammoci

给你两段,我自己写的,可是相换的。  
  function   displaystr(str)  
  str=RTrim(str)  
  if   not   isnull(str)   then  
  str   =   replace(str,   ">",   "&gt;")  
  str   =   replace(str,   "<",   "&lt;")  
  str   =   Replace(str,   CHR(32),   "   ")  
  str   =   Replace(str,   CHR(9),   "   ")  
  str   =   Replace(str,   "   ",   "&nbsp;")  
  str   =   Replace(str,   CHR(34),   "&quot;")  
  str   =   Replace(str,   CHR(39),   "&#39;")  
  str   =   Replace(str,   vbCr,   "")  
  str   =   Replace(str,   vbLf,   "<BR>")  
  str   =   Replace(str,   vbCrLf,   "<BR>")  
  str   =   replace(str,"-","&minus;")  
  displaystr   =   str  
  else  
  displaystr="---"  
  end   if  
  end   function  
   
  function   displaystr1(str)  
  str=RTrim(str)  
  if   not   isnull(str)   then  
  str   =   replace(str,   "&gt;",   ">")  
  str   =   replace(str,   "&lt;",   "<")  
  str   =   Replace(str,   "   ",   CHR(32))  
  str   =   Replace(str,   "   ",   CHR(9))  
  str   =   Replace(str,   "&nbsp;",   "   ")  
  str   =   Replace(str,   "%20",   CHR(34))  
  str   =   Replace(str,   "&#39;",   CHR(39))  
  str   =   Replace(str,   "",   vbCr)  
  str   =   Replace(str,   "<BR>",   vbLf)  
  str   =   Replace(str,   "<BR>",   vbCrLf)  
  str   =   replace(str,"&minus;","-")  
  displaystr1   =   str  
  else  
  displaystr1="---"  
  end   if  
  end   function  
   
   
  有些你不想转的就平掉,然后调用就好了。


 

 
热门推荐笔记本: IBM笔记本
相关文章:
webmaster:popbb@126.com   最佳浏览:1024X768 MSIE
©2007 popbb.net All Rights Reserved