Using HTML Tags for formatting in InfoPath Rich Text Box Control

Nishant Rana's Weblog


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=””>Error Message Header</h2><p xmlns=””>This is my custom <font xmlns=”” 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

Hope it helps..

View original post