Advertisement

07.25.2007 at 06:50AM PDT, ID: 22719836
[x]
Attachment Details

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

Asked by JohanGrundling in Microsoft Visual C#.Net, .Net Editors & IDEs

Tags: javascript, call

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?

Start Free Trial
[+][-]07.26.2007 at 07:34AM PDT, ID: 19574817

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual C#.Net, .Net Editors & IDEs
Tags: javascript, call
Sign Up Now!
Solution Provided By: vilimed
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32