Program and Steps For Compilation and Running ActiveX Control
Program and Steps For Compilation and Running ActiveX Control
Write the code for ActiveX control using notepad and name it as AClass.cs AClass.cs using System; using System.Runtime.InteropServices; namespace ANamespace { public interface ASignatures { string FName(); string SName(); int Age { get;} } [ClassInterface(ClassInterfaceType.AutoDual)] public class AClass :ASignatures { public string FName() { return "I"; } public string SName() { return "N"; } public int Age { get { return 249; } } } }
2. Save it in C:\Program Files\Microsoft Visual Studio 9.0\VC folder 3. Open visual studio 2008 command prompt from start -> all programs 4. To compile the ActiveX control type csc /t:library AClass.cs 5. To register the component type regasm AClass.dll /tlb /codebase
6. Now open another notepad file and enter the javascript code to invoke the component and save it as Activex1.html on Desktop Activex1.html <html> <head> <script language="javascript"> <!-- Load the ActiveX object --> var x = new ActiveXObject("ANamespace.AClass"); <!-- Access the Method --> alert(x.FName()); alert(x.SName()); <!-- Access the Property --> alert(x.Age); </script> </head> <body> </body>
7. Open the ActiveX.html using internet explorer 8. Right click on the yellow ribbon to allow the blocked content