Using HTML Tags for formatting in InfoPath Rich Text Box Control

Hi,

We had a requirement to format custom error messages that we were displaying in the rich text box control inside InfoPath Form.

For this we can use AppendChild method of XPathNavigator object.

For e.g. below is the html we need

The code that we need to use

XPathNavigator richTextField = domNav.SelectSingleNode(“/my:myFields/my:field4”, NamespaceManager);

richTextField.AppendChild(“<h2 xmlns=\”http://www.w3.org/1999/xhtml\”>Error Message Header</h2><p xmlns=\”http://www.w3.org/1999/xhtml\”>This is my custom <font xmlns=\”http://www.w3.org/1999/xhtml\” size=\”3\” color=\”red\”> error </font> message.</p>”);

The output

We need to define namespace for each tag used else we get exception.

The helpful post

http://www.bizsupportonline.net/infopath2007/how-to-render-html-in-rich-text-box-infopath.htm

Hope it helps..


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

1 thought on “Using HTML Tags for formatting in InfoPath Rich Text Box Control”

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s