In many cases, customers often need to implement some complex functions on the client, some can be implemented through Ajax, and some cannot be completed by existing client scripts, in this case, the ActiveX control must be used.
Here is an example of using. Net to compile simple ActiveX and apply it on a webpage:
//////////////////////////////////////// ///////////////////////////////////////// //
// Axcomp. CS
// Creates a simple ActiveX component.
//
// 1. Compile into a class library, or use:
// CSC/T: Library axcomp. CS
// 2. Register and generate the typelib on the client's machine:
// Regasm axcomp. dll/TLB: axcompnet. dll/codebase
//////////////////////////////////////// ///////////////////////////////////////// //
Using System;
Using System. runtime. interopservices;
NamespaceAxcomponent
{
Public InterfaceIaxtest
{
StringCalender ();
}
[Classinterface (classinterfacetype. autodual)]
Public ClassAxcomp: iaxtest
{
Public StringCalender ()
{
Return "This is a test.";
}
}
}
Code
//////////////////////////////////////// //////////////////////////////////////// ///
// Tester.htm
// Test the ActiveX component.
//////////////////////////////////////// //////////////////////////////////////// ///
< Html >
< Head >
< Script Language = Javascript >
VaR G_axcomponent = New Activexobject ( ' Axcomponent. axcomp ' );
Alert (g_axcomponent.cal1 ());
</ Script >
</ Head >
< Body >
< H1 > Tester.htm </ H1 >
</ Body >
</ Html >