Saturday, July 4, 2009

Javascript showModalDialog() - Not impressed

Recently I was working on an ASP.Net page to put in an IFRAME for Microsoft CRM. I had a requirement to choose a CRM systemuser from a list, and so naturally I went looking for a way to do this.

I stumbled across showModalDialog() and thought it was the way to go as it offered a Modal Dialog window which I could put to any URL and also could return any result I wanted back to the calling window really simply.

So, everything seemed to work great, but as it turns out, it IE 8 seems to cache the Dialog window so everytime that you start it up it would show the very first window that you had that ever used it (not just for that session, but the very first time you used the window with that URL). This was really odd, I tried several methods for stopping the caching but none of them seemed to work - even changing the URL to be unique every time didn't even stop it!

At the end of the day I gave up after finding out so many other people were having problems with it, and that it's functionality and become "flakey-er" as new revisions of IE were released (I also discovered that it's an IE only feature).

I ended up just re-arranging my base page (the one that i put in the IFRAME) to include the some functionality.

From now on I'll be avoiding the showModalDialog() - as I wouldn't be surprised if it doesn't work at all in the next version of IE. And although I ended up not using any type of Modal in this instance, I did find examples of how it's possible to do it with standard (non IE specific) code.

Lesson Learnt!

2 comments:

jaime said...

You may want to give a look to:
http://www.ericmmartin.com/projects/simplemodal/

Here is a nice demo:
http://www.ericmmartin.com/simplemodal/

Looking forward to check your LINQ to SQL Entity Base project (AKA Disconnected LINQ).

Greetings from Peru.

Matthew Hunter said...

Thanks.

I'll use this information for the next time!