Add a logo from a SharePoint library to an InfoPath browser form

Learn how you can use a Rich Text Box control and code to display an image for a logo that is stored in a SharePoint Picture Library on an InfoPath browser form.


While I’ve written about displaying images in browser forms before, some of my older posts and comments on questions from visitors got lost in the transition of moving my blog from to

And since you may have difficulty taking the techniques described in my article about how to display images in a repeating table in an InfoPath browser form using a Rich Text Box control to try to display one simple logo on a browser form, I’ve decided to lay out the solution here.

If you have a Rich Text Box control named logo on a browser-compatible InfoPath form template, and you want to display an image named logo.jpg that is stored in a SharePoint Picture Library named MyPictureLib, you could use the following C# code in the Loading event of your InfoPath form template:

XPathNavigator root = MainDataSource.CreateNavigator();
XPathNavigator logoField = root.SelectSingleNode(
"//my:logo", NamespaceManager);
string url = "http://<ServerName>/MyPictureLib/logo.jpg";
logoField.InnerXml = "<img xmlns=\"\" src=\""
+ url + "\"/>";

where ServerName is the name of the SharePoint server or SharePoint site on which the picture library is located.

And remember that since you have written code for the browser-compatible InfoPath form template, you’ll have to perform an administrator-approved InfoPath form deployment.

Updated July 18, 2009:
If you prefer to use Visual Basic, use the following code:

Dim root As XPathNavigator = MainDataSource.CreateNavigator()
Dim logoField As XPathNavigator = root.SelectSingleNode( _
"//my:logo", NamespaceManager)
Dim url As String = "http://<ServerName>/MyPictureLib/logo.jpg"
logoField.InnerXml = "<img xmlns="""" src=""" _
& url & """/>"


Related Posts


Copyright: This article may not be used on web sites (whether personal or otherwise), copied, disseminated, altered, printed, published, broadcasted, or reproduced in any way without an expressed written consent. The techniques demonstrated in this article may be used within any Microsoft InfoPath project. This article is provided without any warranties. Copyright for this article is non-transferrable and remains with the author.