显示html标签的Infopath文本框

问题描述:

如何阻止Infopath在我的文本框中显示html标签?例如,我的文本框有:

How do I stop Infopath from displaying html tags in my text box? For example, my textbox has:

你好

世界!

,但它会在打印预览中显示为:
hello
the world!

but it will show up in the print preview as: "hello

world!"

奇怪的是,Infopath正在将我的文本转换为包含html ..

Strangely, Infopath is converting my text to include html..

不能使用文本框将HTML文本显示为呈现的HTML - 您需要使用丰富的文本框。

You cannot use a textbox to display HTML text as rendered HTML - you will need to use a rich text box.

然后,您必须以编程方式将HTML作为子节点添加到文本框中,如下所示:

You then would have to programatically add your HTML as child nodes to the text box like so:

MainDataSource.CreateNavigator().SelectSingleNode("//my:rtfField", NamespaceManager).AppendChild("<h2 xmlns=\"http://www.w3.org/1999/xhtml\">Header Text</h2><p xmlns=\"http://www.w3.org/1999/xhtml\">This is some paragraph text.</p>");

如何实现您想要的内容的一个很好的解释是:如何让HTML标记显示为HTML而不是纯文本一个富文本框

A good explanation of how to achieve what you want is here: How to get HTML tags to appear as HTML and not as plain text in a Rich Text Box

以及一些与HTML +文本框相关的其他链接: InfoPath中的Rich Text Box

And some further links related to HTML + Textboxes: Rich Text Boxes in InfoPath