activeX control

bwuk

Member
Joined
Nov 4, 2008
Messages
7
Programming Experience
Beginner
Hi,

In the past, I've wrote a couple of VB6 activeX controls that can be embedded in a web page and have passed data to and from the activeX control and javascript in a web page.

I've been given a task of doing the same with VS2008 and VB.Net. I've searched for examples, but most of the examples seem to be C#, and even then, they don't seem to work.

Could someone please help me out? Some source code, a good link, tutorials?

I realise this may look bad on myself, but I'm getting quite frustrated now :)

Thanks


bwuk
 
I am a bit of a newb so this might not be the solution you are looking for. However, I had trouble finding this answer for 2008 express myself so I'll try to help. In Solution explorer right click your application (the first listing in the solution treeview) click properties. In the Application Type: combobox select Class Library.
 
Hi, and thanks for reply :)

I've managed to figure out how to create the user control, but where I'm becoming stuck is:

1) How do expose methods as public so javascript in a web page can interact with the user control
2) How to make calls to the javascript from the user control
3) How to export the user control to an activeX control.


Thanks


bwuk
 
Hi,

That's the one example I did find, but it doesn't look complete. It looks like it's talking about VB.net, but some of the syntax looks like C#.

Does that make any sense? :)


bwuk
 
Ok, so what I've done is create a new VB class library. Removed the form and added a new user control called myControl.

I've changed my project name to ActiveXDotNet and added a txt field to the control called txtUserText.


And my user control code now looks like:


VB.NET:
Namespace ActiveXDotNet

    Public Interface AxMyControl
        Property UserText() As String
        End Property
    End Interface 'AxMyControl

    Public Class myControl
        Inherits System.Windows.Forms.UserControl, AxMyControl
        Private mStr_UserText As [String]

        Public Property UserText() As String
            Get
                Return mStr_UserText
            End Get
            Set(ByVal Value As String)
                mStr_UserText = value
                'Update the text box control value also.
                txtUserText.Text = value
            End Set
        End Property
    End Class 'myControl

This throws the following errors:

Error 1 'Namespace' statement must end with a matching 'End Namespace'. C:\Users\Ian\AppData\Local\Temporary Projects\ClassLibrary1\myControl.vb 1 1 ActiveXDotNet


Error 2 Statement cannot appear within an interface body. C:\Users\Ian\AppData\Local\Temporary Projects\ClassLibrary1\myControl.vb 5 9 ActiveXDotNet


Error 3 'Inherits' can appear only once within a 'Class' statement and can only specify one class. C:\Users\Ian\AppData\Local\Temporary Projects\ClassLibrary1\myControl.vb 9 9 ActiveXDotNet


Error 4 Name 'txtUserText' is not declared. C:\Users\Ian\AppData\Local\Temporary Projects\ClassLibrary1\myControl.vb 19 17 ActiveXDotNet



Any ideas?


bwuk
 
try
VB.NET:
Namespace ActiveXDotNet
    Public Interface AxMyControl
        Property UserText() As String
    End Interface 'AxMyControl
End Namespace
Public Class myControl
    Private mStr_UserText As String
    Public Property UserText() As [String]
        Get
            Return mStr_UserText
        End Get
        Set(ByVal Value As [String])
            mStr_UserText = Value
            'Update the text box control value also.
            txtUserText.Text = Value
        End Set
    End Property

End Class 'myControl
 
Hi,

Thanks so much for your help! I've managed to compile the DLL. I've copied all the release files into the same directory as my html document. However, when I goto the page in IE, all I get is a blank area with the standard IE 'missing' icon in the top left - like when an image doesn't exist.

I've added my url to my trusted sites, but it still doesn't work.

I'm running apache if that makes any difference


Thanks


bwuk
 
That link had a download that did the trick :) Thank you very much for your help. From start to finish :D

hmm.....I don't suppose you know how to call a javascript function from an activeX control do you? that's the last part of the puzzle


bwuk
 
Back
Top