Infopath textbox displaying html tags

2019-08-22 03:59发布

问题:

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

"Hello

World!"

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

world!"

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

回答1:

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

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>");

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

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