Link to home
Start Free TrialLog in
Avatar of JohanGrundling
JohanGrundling

asked on

How to call JavaScript from a embedded c# dll in object tag in a web page

I would like to call JavaScript from a c# component (dll) embedded in an html page with the  object tag.

So far I have got the following sample code that I have taken from other forums and google searches.

In the HTML page I have:

<OBJECT id="myControl" name="myControl" style="WIDTH: 208px; HEIGHT: 176px" height="176" width="208" classid="dll/ActiveXControl.dll#ActiveXControl.ButtonControl" VIEWASTEXT>
</OBJECT>

and:

<script type="text/javascript" for="myControl" event="objectClicked(sender)" >
{
    alert("message");
}
</script>


In my c# windows control project I have the following code:

public delegate void SelectClickEventHandler(object sender);

public class ButtonControl : System.Windows.Forms.UserControl
  {
         public event SelectClickEventHandler objectClicked;


// the rest of the component code follows

// then when I want to raise the event I call

private void ButtonControl_Click(object sender, System.EventArgs e)
{
      if (objectClicked != null)
             objectClicked(this);
}


Am I on the right track and if so any suggestions on how to get it to work or is there another method I could use?

ASKER CERTIFIED SOLUTION
Avatar of vilimed
vilimed

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial