备注型字段写入读出的显示问题。
如果用<textarea></textarea>写入数据库,用Replace(dbrs("aa"), Chr(13) & Chr(10), "<br>")显示在网页上的话会导致HTML代码无法正确地显示出来。如何既能正确显示HTML代码,又能保持格式完整?
还有半角空格的写入和显示问题,半角'的写入和显示问题,还有我没想到和遇到的问题,
最好能给我一套完整的处理写入的代码和一段处理显示的代码,我现在只有一个人在做ASP,又没有人交流,不知道规范的做法应该是怎样的。
问题点数:50、回复次数:2Top
1 楼freezwy(网络自由人)回复于 2001-05-31 13:12:00 得分 50
仅仅在写入时调用下面这个函数,显示时就不用了.
<%
function htmlencode2(str)
dim result
dim l
if isNULL(str) then
htmlencode2=""
exit function
end if
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case chr(13)
result=result+"<br>"
case chr(34)
result=result+"""
case chr(32)
'result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case chr(9)
result=result+" "
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function
%>
Top
2 楼shgz()回复于 2001-05-31 14:49:00 得分 0
我从来没有用过自己写的函数,不知道应该如何调用?Top




