Microsoft CRM 2011 -- When to Use an iFrame vs a Web Resource

Visit Website View Our Posts

Sit back and relax a bit because we aren’t going to get into any code today.  Instead we are going to take a higher level look at some interesting caveats within CRM 2011.

Even if you aren’t a developer, if you customize the form with Web Resources or iFrames, this should be helpful to you.


First of all, I came across this due to a colleague using Silverlight.  Like many of you out there, we do some crazy stuff with Silverlight.  Silverlight is awesome and can be leveraged to do some serious heavy lifting.  I’m actually more of a JavaScript guy, but until JavaScript supports multi-threading, Silverlight cannot be overlooked.

When using Silverlight, you have three options to put Silverlight on your form:

  • Embed a Web Resource and select the XAP file (Figure A – 1)
  • Embed a Web Resource and select an HTML wrapper (Figure A – 3)
  • Embed an iFrame and enter an HTML wrapper (Figure A – 4)



Figure A (Before)

If you are embedding the XAP file (1), then all is good in the world and everything should behave like any other control.  Problems only arise with the magnitude of what you are doing.  Let’s say you have a couple of JavaScript resources you need to support your Silverlight control to talk to the form.  If that’s the case, setup and maintenance is a little more cumbersome.

To make life easier for you and your customer, you could upload your own HTML file with everything self-contained.  Now that you have everything nicely contained in an HTML web resource, we can either insert a web resource and select our HTML file (3) or we can use an iFrame and point to our HTML file (4).  What’s the difference?  Watch what happens when I select a Related entity (e.g. Activities) and then come back to my form.  Notice how the Web Resource is blank?  That’s because the form reloaded my web resource.


Figure B (After)



Ok, some of you out there may be saying, “but I don’t use Silverlight”.  That’s fine, but this actually applies to HTML files as well.  When embedding an HTML page, again you can either use a web resource or an iFrame.  If you choose a web resource however, the page will reload when toggling to a new related entity.  If you choose an iFrame, it will NOT reload (look back at Figure A&B paying attention to 2 and 5).


Well why?

This is all about your purpose.  If you have a HTML page or Silverlight control that is read-only (e.g. graphs, charts, or accessing another system), then a Web Resource would be the better method most of the time.  If you are expecting users to input data, then you’ll want to use an iFrame instead of a Web Resource so that the data is persistent.  For some of you this could be a gotcha and for others it can be a feature.  Hopefully none of your users are on the wrong end of this!  Enjoy.

Post by: Paul Way, Customer Effective

Show Buttons
Hide Buttons