转换特殊字符为HTML实体,在不改变标签和参数 [英] Convert special chars to HTML entities, without changing tags and parameters

查看:186
本文介绍了转换特殊字符为HTML实体,在不改变标签和参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用FreeTextBox编辑器让用户创建一些HTML。
这个问题是在HTML实体在<>的外,这个编辑器没有转换特殊字符。我不能使用 theHTML = Server.HtmlEn code(theHTML),因为它转换所有的HTML包括变量和参数,我不希望创建一个unfinishable的 theHTML.Replace 行列表。

I'm using FreeTextBox editor to get some HTML created by users. The problem with this is this editor is not converting special chars in HTML entities at exception of "<>". I cannot use theHTML = Server.HtmlEncode(theHTML), because it converts all the HTML including tags and parameters, and I don't want to create an unfinishable list of theHTML.Replace lines.

是否有可用的任何其他函数或方法转换为HTML实体,但只能在外面的标签?

Is there any other function or method available to convert to html entities but only outside tags?

推荐答案

搜索了很多之后,我发现,我用的是FreeTextBox组件的错误属性。该物业是的 ConvertHtmlSymbolsToHtml codeS 至极必须是真实的。

After searching a lot, I've found that I was using the wrong property of the FreeTextBox component. The property was ConvertHtmlSymbolsToHtmlCodes wich has to be true.

这也有助于使用 FormatHtmlTagsToXhtml 如果您需要插入您的code到XHTML页面,因为它使用与标签的参数和报价围绕它们强大的验证。

It also helps to use FormatHtmlTagsToXhtml if you need to insert your code into XHTML pages, because it uses a strong validation with tags parameters and quotes surrounding them.

这篇关于转换特殊字符为HTML实体,在不改变标签和参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆