Tuesday, December 4, 2007

InfoPath: How to display images in browser-based forms

Use the following method to add an image to a browser-based form in InfoPath 2007 using C# managed code:

Your image must be available somewhere by URL.
1. Add a rich text control to the form.
2. Add the following code to the form:

XPathNavigator ng = MainDataSource.CreateNavigator().SelectSingleNode("XPath to the binding of the rich text control", NamespaceManager);
ng.AppendChild("<img xmlns=\"http://www.w3.org/1999/xhtml\" src=\"URL of your image\" />");

This modifies the XML node of the rich text box, adding an XHTML image as a child.

No comments: