Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I make an ActiveX control written with C# raise events in JavaScript when clicked?
    primarykey
    data
    text
    <p>I'm seeing a few questions related to this on SO already, but I think mine is sufficiently different to not be considered a duplicate (if I'm wrong let me know).</p> <p>I have an ActiveX control I've written in C# and while I have it mostly working, I want to raise an event in JavaScript when it's clicked (it displays an image so it's a visual element on the page). </p> <p>The end goal of what I'm looking to accomplish is no different than if it were a <code>&lt;span&gt;</code> tag and it had an <code>onclick</code> event to raise a JavaScript function when the area of the tag were clicked.</p> <p>Most of the <a href="https://stackoverflow.com/questions/150814/how-to-handle-an-activex-event-in-javascript/379872#379872">stuff I've read</a> on it goes into very fine detail on how to handle events in an ActiveX control and send info back/forth, and that's fine, but it seems overly complicated. I'm not looking to communicate with the ActiveX control, I just need a JavaScript function to fire off when I click it, in a way similar to a <code>&lt;span&gt;</code> or <code>&lt;div&gt;</code> tag. I can handle everything else in JavaScript. Simply wrapping the control in a <code>&lt;span&gt;</code> or <code>&lt;div&gt;</code> with an <code>onclick</code> event has no effect - the ActiveX control pretty much overrides it.</p> <p>Is there a simple way to handle this for an ActiveX control written in C#?</p> <p>I guess another way of putting it is - I'm working with a third party control and we have to use code similar to the following to get it to communicate with our HTML page via JavaScript</p> <pre><code>&lt;script type="text/javascript" event="OnMouseClick(index)" for="AXObjectName"&gt; &lt;!-- AXObjectName_OnMouseClick(index); //--&gt; &lt;/script&gt; </code></pre> <p>Where <code>AXObjectName</code> is the name/id of the control and <code>AXObjectName_OnMouseClick</code> is the name of the JavaScript function it will fire in my code, passing an <code>index</code> parameter. However, what all do I have to do to set up a method like <code>OnMouseClick</code> in the control? And if I don't want to pass any actual information (i.e., no <code>index</code>) do I even have to go this far?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload