First, create the dll library, Code As follows:
Using system;
Using system. runtime. interopservices;
Namespace anamespace
{
// Define the COM Component Interface
Public interface asignatures
{
String fname ();
String sname ();
Int age {Get ;}
}
// Indicates that this class will be exposed as an interface of a COM Component
[Classinterface (classinterfacetype. autodual)]
Public class Aclass: asignatures
{
// Method for implementing the interface
Public String fname ()
{
Return "Imran ";
}
Public String sname ()
{
Return "nathani ";
}
Public int age
{
Get {return 24 ;}
}
}
}
Save the above Code as Aclass. CS, and then compile: CSC/T: Library Aclass. CS
You will get an Aclass. dll, and then register: regasm Aclass. dll/TLB/codebase
Finally, create an HTML test webpage with the following content:
<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>
</Html>
Download the sample file:/files/margiex/testcom.rar
Source: http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx