一个HtmlEncode函数,如下: public static string HtmlEncode(string theString)
{
//theString = theString.Replace(">", ">");
//theString = theString.Replace(" <", "<");
theString = System.Text.RegularExpressions.Regex.Replace(theString, @"<(?!(a\s+)|(/a>))([^<>]*?)>", "<$3>");
// theString = theString.Replace(" ", " ");
theString = System.Text.RegularExpressions.Regex.Replace(theString, @" (?![^>]*>)", " ");
theString = System.Text.RegularExpressions.Regex.Replace(theString, @"""(?![^>]*>)", """);
theString = System.Text.RegularExpressions.Regex.Replace(theString, @"'(?![^>]*>)", "'");
//theString = theString.Replace("\"", """);
//theString = theString.Replace("\'", "'");
theString = theString.Replace("\n", " <br/> ");
return theString;
}问题:
当我用Fckeditor插入文字时,切换到html显示
<p> </p>
<p>csdn</p>
<p><a href="www.baidu.com">baidu</a></p>
<p> </p>插入后,页面直接显示成
<p> </p>
<p>csdn</p>
<p><a href="www.baidu.com">baidu</a></p>
<p> </p>如何修改该方法使之能正常显示!!!
{
//theString = theString.Replace(">", ">");
//theString = theString.Replace(" <", "<");
theString = System.Text.RegularExpressions.Regex.Replace(theString, @"<(?!(a\s+)|(/a>))([^<>]*?)>", "<$3>");
// theString = theString.Replace(" ", " ");
theString = System.Text.RegularExpressions.Regex.Replace(theString, @" (?![^>]*>)", " ");
theString = System.Text.RegularExpressions.Regex.Replace(theString, @"""(?![^>]*>)", """);
theString = System.Text.RegularExpressions.Regex.Replace(theString, @"'(?![^>]*>)", "'");
//theString = theString.Replace("\"", """);
//theString = theString.Replace("\'", "'");
theString = theString.Replace("\n", " <br/> ");
return theString;
}问题:
当我用Fckeditor插入文字时,切换到html显示
<p> </p>
<p>csdn</p>
<p><a href="www.baidu.com">baidu</a></p>
<p> </p>插入后,页面直接显示成
<p> </p>
<p>csdn</p>
<p><a href="www.baidu.com">baidu</a></p>
<p> </p>如何修改该方法使之能正常显示!!!
解决方案 »
- win7 vs2010 突然页面无法访问了.
- winform中的mainMenu怎么设置它的颜色?
- 将服务器Session信息存储在SQL Server中,会不会很影响WEB服务器的速度呢??
- 很喜欢树 我写了很多版本的树 评价一下这个ajax版本的树
- 如何将string类型转换成ArrayList类型?
- ooReport网上直报数据分析平台-WEB服务器端(IIS版) 现在供大家下载测试一下,提一下建议!
- asp.net CheckBoxList 的数据是从数据库读取的,现在想初始化一个值
- 输出日期,如果是今天,就显示红色,不然就显示黑色
- 保持session
- jqgrid,有数据,但页面不显示,求大神看下
- 如何计算字符串的字节长度
- JS简单问题
Html显示如下
<p> </p>
<p>csdn</p>页面正常显示为
<p> </p>
<p>csdn </p>求高手修改一下,急!!!