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/ActiveXContro l.dll#Acti veXControl .ButtonCon trol" VIEWASTEXT>
</OBJECT>
and:
<script type="text/javascript" for="myControl" event="objectClicked(sende r)" >
{
alert("message");
}
</script>
In my c# windows control project I have the following code:
public delegate void SelectClickEventHandler(ob ject sender);
public class ButtonControl : System.Windows.Forms.UserC ontrol
{
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?
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/ActiveXContro
</OBJECT>
and:
<script type="text/javascript" for="myControl" event="objectClicked(sende
{
alert("message");
}
</script>
In my c# windows control project I have the following code:
public delegate void SelectClickEventHandler(ob
public class ButtonControl : System.Windows.Forms.UserC
{
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
{
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.