Click here to Skip to main content
15,867,282 members
Articles / Web Development / ASP.NET
Article

Removing activation for ActiveX objects in IE

Rate me:
Please Sign up or sign in to vote.
3.65/5 (8 votes)
18 May 20063 min read 217.3K   925   47   23
A class you can use with any ASP.NET web-control to automatically activate an interactive control in IE

Introduction

The latest Microsoft patch for Internet Explorer included a change to ActiveX requiring all interactive controls to activate before they can be used. This change has impacted web applications all over the world including Dundas products.

Image 1
Figure 1: Chart rendered as a Flash image requiring activation

While the Chart can still be viewed fine after this patch as an image or an ActiveX object, the interactivity included in ActiveX objects, such as Flash, require a preliminary click by the user. This is not attractive functionality and fortunately Microsoft has released an article detailing how to fix it.

We have gone a step further and implemented a class library based on the Microsoft article that you can use with any web-control to automatically activate an interactive control. To use this class library, simply add the class to your solution and the namespace Dundas.Utilities to the webpage that uses a web-control that renders as an ActiveX object. As well, you may need to change the security for the root directory of the web application to allow your ASPNET user to write.

Next, the Page_Load event requires the following code (note that this.Chart1 is the web-control rendering as an ActiveX object):

AutoActivateControl autoActivateControl = new AutoActivateControl(this.Chart1);

That's it! Your control will no longer require activation before interactivity can be used.

How this control works

This control works based based on the notion that while Internet Explorer cannot activate any control embedded directly into it automatically, an object added to the page via an external JavaScript file can be automatically activated. As such, the control performs the following steps upon instantiation:

  1. Attaches to the PreRender event of the web-control passed to it.
  2. Upon the PreRender event, forces the web-control to render into memory instead of to the HTML output page and turns the Visibility property of the web-control to false so that it does not render to the output page.
  3. The control then creates a JavaScript file in the root folder of the application named embed.js (if the file is locked by another IIS thread, the control will create a more unique filename such as embed723.js).
  4. Once the file is created, a JavaScript line is added to it with the contents of the web-control's rendered output. It will look something like:
    document.write('<object ...> ... </object>')
  5. The last step the control performs is to embed a line into the HTML output page that refers to this external JavaScript file:
    <script src="/embed.js"></script>

A little more information

It should be noted that the information provided in this article is not a "trick" or "hack", it is implementation of the method recommended by Microsoft. The activation functionality in itself was caused by a patent violation involving interactive objects embedded directly in a browser. The method described in this article is allowed because embedding it in an external JavaScript file means that it is no longer directly embedded in the browser.

Also, please note that this is a direct implementation of Microsoft's recommendation and is very simplistic. While it does work in basic cases, it will require modification to work in most real environments. It is provided as a base for further modification by those who require this functionality.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
Since 1992 Dundas Data Visualization has been helping companies all over the world visualize their data. Dundas products have a global reputation of being the highest quality, and are all designed, built and tested to meet the strictest requirements that developers and business managers demand.

Our showcase product is Dundas Dashboard, an easy-to-integrate digital dashboard software solution. Dundas Dashboard allows for the rapid and collaborative development of performance dashboards, helping companies leverage their business intelligence (BI) solutions.

Our web-based dashboard software comes with wizard interfaces, and a unique Dundas DashFlowTM process, allowing for the simultaneous development of an executive dashboard by business analysts, IT staff and database administrators. It also uses premier charts, maps, gauges and graph controls, letting end-users visualize their data as required.

Dundas also offers superb, world class consulting services for those companies that do not have the in-house expertise to implement their data visualization projects.

The quality of our products in conjunction with our unmatched technical support, numerous awards and years of experience reflect Dundas Data Visualization's commitment to being the best!
This is a Organisation

3 members

Comments and Discussions

 
QuestionBlank Screen Pin
qasd348-Feb-07 13:37
qasd348-Feb-07 13:37 
GeneralNew automatic HTML file fix tool Pin
FunkyMonkey1-Jul-06 6:33
FunkyMonkey1-Jul-06 6:33 
GeneralA better solution Pin
Richard Deeming25-May-06 1:51
mveRichard Deeming25-May-06 1:51 
GeneralRe: A better solution Pin
Terrence Sheflin25-May-06 4:08
Terrence Sheflin25-May-06 4:08 
GeneralRe: A better solution Pin
Richard Deeming26-May-06 6:12
mveRichard Deeming26-May-06 6:12 
GeneralRe: A better solution Pin
VKJ761-Jun-06 8:31
VKJ761-Jun-06 8:31 
GeneralRe: A better solution Pin
FunkyMonkey1-Jun-06 16:24
FunkyMonkey1-Jun-06 16:24 
AnswerRe: A better solution Pin
Richard Deeming2-Jun-06 2:46
mveRichard Deeming2-Jun-06 2:46 
GeneralAutoActivating the &lt;object&gt; tag Pin
fernandodelagarza24-May-06 7:14
fernandodelagarza24-May-06 7:14 
GeneralRe: AutoActivating the &lt;object&gt; tag Pin
Terrence Sheflin25-May-06 4:04
Terrence Sheflin25-May-06 4:04 
GeneralActivating Multiple ActiveX controls in same page Pin
VKJ7624-May-06 6:46
VKJ7624-May-06 6:46 
GeneralRe: Activating Multiple ActiveX controls in same page Pin
Terrence Sheflin25-May-06 4:00
Terrence Sheflin25-May-06 4:00 
GeneralRe: Activating Multiple ActiveX controls in same page Pin
VKJ7626-May-06 10:04
VKJ7626-May-06 10:04 
GeneralRe: Activating Multiple ActiveX controls in same page Pin
Terrence Sheflin26-May-06 10:09
Terrence Sheflin26-May-06 10:09 
GeneralRe: Activating Multiple ActiveX controls in same page Pin
VKJ7630-May-06 6:31
VKJ7630-May-06 6:31 
GeneralRe: Activating Multiple ActiveX controls in same page Pin
VKJ7630-May-06 6:43
VKJ7630-May-06 6:43 
GeneralRe: Activating Multiple ActiveX controls in same page Pin
Terrence Sheflin30-May-06 6:55
Terrence Sheflin30-May-06 6:55 
GeneralRe: Activating Multiple ActiveX controls in same page Pin
VKJ7630-May-06 7:38
VKJ7630-May-06 7:38 
GeneralRe: Activating Multiple ActiveX controls in same page Pin
VKJ7630-May-06 7:59
VKJ7630-May-06 7:59 
GeneralRe: Activating Multiple ActiveX controls in same page Pin
VKJ7630-May-06 8:22
VKJ7630-May-06 8:22 
GeneralRe: Activating Multiple ActiveX controls in same page Pin
Terrence Sheflin30-May-06 10:47
Terrence Sheflin30-May-06 10:47 
The easiest way around the problem would be for the AutoActivateControl to store the Randomly generated # into a Session, and then have the chart pull that session out for each item (ie. Session["Chart4"]).

If you are using it in a more complicated situation, I may also recommend using the control written by Richard Deeming which basically extends this class to be much more versatile. He has responded to this article and I'm sure would send you the source he sent me (until it's posted to this article).
QuestionMicrosoft's reason for this? Pin
Clear Demon23-May-06 22:58
professionalClear Demon23-May-06 22:58 
AnswerRe: Microsoft's reason for this? Pin
Terrence Sheflin24-May-06 4:06
Terrence Sheflin24-May-06 4:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.