Julie Lerman's DevLife

DevLife Part I [May 2005 - March 2007]

My Links

Blog Stats

News

A blog for DevSource.com.

This blog was originally part of the blogs.ziffdavis.com site from May 2005 through June 2007 when the blog was moved to the Movable Type blog engine and hosted at blog.devsource.com/devlife.
The original blog was eventually shut down and I was given the posts so that I could host them on my own site.


Archives

IE7 and Embedded Objects (and a little ink, too)

IE6 patches brought a new "feature" hated by many to the browser: "Click to activate and use this control." It was Microsoft's solution to a lawsuit and affected pages that had OBJECT, APPLET or EMBED tags in it. You may have seen this with pages that have Flash or embedded Windows Media players, for example. I thought I had seen a patch to remove this somewhere on the Microsoft site but can no longer find it. However it is now part of IE7 and there is no avoiding it. Unless web developers are kind enough to apply a workaround to their sites, that is.

The "feature" is a little more annoying with embedded ink controls. When the user "clicks" on the embedded control with a stylus, they inadvertantly add an ink stroke to the ink surface. Depending on the user and the default characteristics of the drawing pen, that might be a little dot or a big fat line.

There are workarounds. The trick is not to have the tags directly in the html. Instead, dynamically insert them with some javascript. Here's one from Adobe and here is an MSDN article as well. I'm using a simple js file that contains my object tag then calling that js file in the place where I would normally use the tag in my html.

My InsertObj.js file

document.write(' <object id="InkControl" classid="MyInkControls.dll#MyInkControls.SimpleInkControl" height="248"width="344"></object>');

My HTML

(note I have put extra white spaces in my html to attempt to overcome an encoding problem with this blog)

< body ...>
< form id="form1" runat="server">
           < div>
                   <script src="InsertObj.js"></script>
 ....etc....

This works perfectly fine. But I wanted to remove one more layer, which was re-creating the embedded object at postback - just because I can! Atlas (err - Microsoft AJAX) to the rescue.

All I had to do was put everything related to the postback (the button that triggered the server side call) onto an UpdatePanel and leave the embedded object outside of the updatepanel. Now when I click the button to do something on the server side and the page posts back, the object stays put and does not have to be re-rendered. Works lke a charm.

posted on Wednesday, October 25, 2006 5:06 PM