[写进数据库时调用]
'<script language='javascript'>
'<!--///用户前台aspx提交时///
'// 替换特殊字符
'function HTMLEncode(text)
'{
' text = text.replace(/&/g, "&") ;
' text = text.replace(/"/g, """) ;
' text = text.replace(/</g, "<") ;
' text = text.replace(/>/g, ">") ;
' text = text.replace(/'/g, "’") ;
' text = text.replace(/\ /g," ");
' text = text.replace(/\n/g,"<br>");
' text = text.replace(/\t/g," ");
' return text;
'}
'//-->
'</script>
[数据读取时调用]
Public Shared Function TextToHtml() As String
If _Text <> Nothing Then
_Text = _Text.Replace("<", "<")
_Text = _Text.Replace(">", ">")
_Text = _Text.Replace(" ", Chr(32))
_Text = _Text.Replace("’", "'")
_Text = _Text.Replace(""", ControlChars.Quote)
'//_Text = _Text.Replace("&", "&")
_Text = _Text.Replace("<br>", Chr(13))
Return _Text
Else
Return Nothing
End If
End Function