textarea 回车换行空格等字符存入数据库并读取
录入数据库时
str = Replace(str,vbCrlf, "<br/>" )
这样页显示的时候就有换行了
当要编辑信息时
str = Replace(str," <br/>" ,vbCrlf)
这样放到编辑的textarea上时就有换行了
写到数据库的内容,读出来时没有了空格和换行,类似问题的解答就是在写入数据库做Replace替换
<%
'----------Html转换为文本:编辑时拿来做转换
Function Html2Text(Str1)
If isNULL(Str1) Then
Html2Text=""
Exit Function
End If
Str1=Replace(Str1,"<"," <")
Str1=Replace(Str1,">",">")
Str1=Replace(Str1," <br>",VBcrlf)
Str1=Replace(Str1,""",chr(34))
Str1=Replace(Str1," "," ")
Str1=Replace(Str1,"&","&")
Html2Text=Str1
End Function
'-------------------文本转换为Html:写入数据库时使用---------------
Function Text2Html(Str1)
If isNULL(Str1) Then
Text2Html=""
Exit Function
End If
Str1=Replace(Str1,"&","&")
Str1=Replace(Str1," <","<")
Str1=Replace(Str1,">",">")
Str1=Replace(Str1,VBcrlf," <br>")
Str1=Replace(Str1,chr(34),""")
Str1=Replace(Str1,chr(9)," ")
Str1=Replace(Str1," "," ")
Text2Html=Str1
End Function
%>
输出时如果不是在文本框就不用text2html