An ActiveX control is an object that supports a customizable programmatic interface. Using the methods, events and properties exposed by the control, web developers can automate their web pages to give the functionality which is equivalent to that of a desktop application.
Introduction
ActiveX
comes to the rescue.This is mostly for webapplications where the users would not be apprehensive about doing a one time installation of the component. Also, in an intranet application these components can be a big boost to the functionality of the application.
Writing ActiveX Class in C#
ASignatures
which holds the signatures of the methods and properties. These methods and properties can then be accessed via JavaScript at the browser level. By default all members of aninterface
are abstract
and public
.The main
ActiveX
class AClass
will inherit from this interface
. Above the mainActiveX
class we will mention the ClassInterfaceType
as AutoDual
. This will indicate the type of the interface
generated for the main class which will automatically be generated and exposed to the COM
. Normally AutoDual
is not recommended because it has some versioning limitations.We will use the
ClassIntrefaceType
as AutoDual
because the purpose of this code is instructional. In the main class we will write two methods FName()
, and SName()
and one property Age
. In our example we will return the basic datatypes
but this can be implemented for complex datatypes
too.01.
using
System;
02.
using
System.Runtime.InteropServices;
03.
namespace
ANamespace
04.
{
05.
06.
public
interface
ASignatures
07.
{
08.
string
FName();
09.
string
SName();
10.
int
Age {
get
;}
11.
}
12.
13.
[ClassInterface(ClassInterfaceType.AutoDual)]
14.
public
class
AClass :ASignatures
15.
{
16.
public
string
FName()
17.
{
18.
return
"Imran"
;
19.
}
20.
public
string
SName()
21.
{
22.
return
"Nathani"
;
23.
}
24.
public
int
Age
25.
{
26.
get
{
return
24; }
27.
}
28.
}
29.
}
0 comments:
Post a Comment