Swapping Images in InfoPath

I'm using InfoPath a little more for this one particular project.  It's very interesting because the project is disconnected for the most part.  We are using InfoPath and satellite phones to communicate a ship's status back to the corporate offices.  I ran into a problem that caused me quite a bit of trouble and I wrote about, here’s an excerpt:

All I wanted to do was swap out images.  I searched high and low and found all kinds of great articles with web services and other nonsense.  But I couldn't find anyplace that would show me how I could just simply swap out an image.  So I thought I'd write a short article on it.
This is really simple if you don't try to make it too hard.  The Picture Control can either have the source linked or embedded.  The embedded control converts the image to a string and stores the entire image in the xml document.  The linked lets you put in a URL to the image.   I want to make a relative link to an image in the resource file.  So I need to create it as linked.  I then created a node in my data source called MapName and set the binding of my control to MapName.  MapName is intended to hold the name of the image that is to be  displayed.  I can set this MapName value with a function similar to this:

function setMapName(mapName){
    XDocument.DOM.selectSingleNode("/my:myFields/my:VesselStatus/my:vesselLocation/my:MapName").text = MapName;

When the value in the MapName changes the form renders the new image automatically.  This helped me to understand that the form undergoes a transformation after every change to the data.

Essentially I just wanted to swap out images and I was trying to use the picture control.  That was a very bad idea, because it sends the image information in the document.  I'm working with satellite phones and they charge by the bit.  I finally  realized that what I needed to do was mark up the stylesheet (view.xsl).  Once I got that figured out everything else pretty much fell into place.  InfoPath is a very nice tool, but it only gets us so far.  I wonder what version Next has in store for us.

  • Facebook
  • DZone It!
  • Digg It!
  • StumbleUpon
  • Technorati
  • Del.icio.us
  • NewsVine
  • Reddit
  • Blinklist
  • Furl it!
Post a comment!
  1. Formatting options

Rss Feed
    follow me on Twitter

    Where I'm Going

    Some Writing I've Done

    Chat With Me