Avatar of tomerbar
tomerbar

asked on 

How do I connect between the ActiveX and the JavaScript?

Hello all,
I've been trying to create an ActiveX to run on my website.
I made the dll, packed it as a .cab file and certified it.
Made the HTML and Javascript parts and ran it on my Apache webserver and I keep getting Javascript error.
I cant seem to invoke the ActiveX functions.

I made sure the cab is certified and installed correctly and it is, I took care of the GUID, I wrote everything as I read on the net (The attache link).

Attached is the c# code (very simple).
Then there is the Javascript, that seems to break at this line: "var x = new ActiveXObject("ClassLibrary1.Class1");"
And the final thing is the HTML object embedded.

I think maybe I'm compiling the C# wrong or something... can someone see what i'm doing wrong?
using System;
using System.Runtime.InteropServices;
 
namespace ClassLibrary1 
{
 
  public interface ASignatures
  {
    string FName();
    string SName();
    int Age { get;}  
  }
 
  [ClassInterface(ClassInterfaceType.AutoDual)]
  public class Class1 :ASignatures
  {
    public string FName()
    {
      return "Imran";
    }
    public string SName()
    {
      return "Nathani";
    }
    public int Age
    {
      get { return 24; }
    }
  }
}
 
 
 
<script type="javascript">
function NotifyActiveX(e)
{
	if ( e.readyState != 4 ) return;
 
	alert("ASD3");
	var x = new ActiveXObject("ClassLibrary1.Class1");
	alert(x.FName());
}
</script>
 
<OBJECT 
  id="LabelControl"
  onReadyStateChange="NotifyActiveX(this)"
  classid="CLSID:133DF296-A49B-4c97-8438-7BD07D5E631D"
  codeBase="Cab1.CAB">
<b>ActiveX is not supported</b>
</OBJECT>

Open in new window

.NET ProgrammingWeb ComponentsJavaScript

Avatar of undefined
Last Comment
tomerbar

8/22/2022 - Mon