Click to See Complete Forum and Search --> : How to pass parameters from HTML page to ActiveX control


Rajesh Gupta
June 19th, 2001, 03:52 AM
You can invoke activeX control from HTML page using CLSID and can pass the parameters using PARAM tag.But how can we access these parameters in activeX control.
Can anyone help?

cksiow
June 20th, 2001, 09:00 AM
I might misunderstood your question, but the PARAM parameters should be the property of the activeX control which of course accessible by the activeX control itself.

for instance, I got the code in a HTML file

<OBJECT ID="Label1" WIDTH=200 HEIGHT=67
CLASSID="CLSID:978C9E23-D4B0-11CE-BF2D-00AA003F40D0">
<PARAM NAME="Caption" Value="testing">
<PARAM NAME="ForeColor" Value="16777215">
</OBJECT>

as you can see, I pass two parameters to the activeX control (a normal label control), i.e. Caption & ForeColor.

if you want to access the parameters in the activeX itself, it would be .Caption & .ForeColor



HTH

cksiow
http://vblib.virtualave.net - share our codes

Rajesh Gupta
June 21st, 2001, 03:55 AM
Ok you have passed parameters Caption and foreColor to ActiveX control.
If now I want to print this Capion on UserControl_Initialize() how can it do it.
I tried with UserControl1.Caption but giving error
DO I have to create property for Caption in ActiveX Control.

Following is code I have written but giving error

Private Sub UserControl_Initialize()
MsgBox Caption
MsgBox UserControl1.Caption
End Sub

cksiow
June 21st, 2001, 04:45 AM
DO I have to create property for Caption in ActiveX Control - yap, you do.



HTH

cksiow
http://vblib.virtualave.net - share our codes

Rajesh Gupta
June 21st, 2001, 05:37 AM
But it still not working.

I will write what I have done.

HTML Code :--

<HTML>
<BODY topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>
<OBJECT ID="project1" WIDTH=300 HEIGHT=200
CLASSID="CLSID:73310882-63E6-11D5-B368-0000F6C1326C">
<PARAM NAME="GetName" VALUE="Rajesh">
</OBJECT>
</BODY></HTML>


AciveX Control Code :---

Option Explicit
Private ls_name As String


Private Sub UserControl_Initialize()
MsgBox ls_name
End Sub


Public Property Get GetName() As String
GetName = ls_name
End Property

Public Property Let GetName(ByVal vNewValue As String)
ls_name = vNewValue
End Property




Instead of showing "Rajesh" value passed from HTML page it is not showing any thing.

I want to display "Rajesh" in MsgBox the value passed from HTML page.

Why it's not working.Please help.

Cimperiali
June 21st, 2001, 06:44 AM
Private Sub UserControl_Initialize()
MsgBox ls_name
End Sub

this is displaied when you create the object, event that happens before you set the property...
Make a new method (= a public sub in your activex)
and call it after setting object value from page.
Or, in Property Let sub add this line
msgbox ls_name




Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.

cksiow
June 21st, 2001, 08:47 AM
Cimperiali has answered.


HTH

cksiow
http://vblib.virtualave.net - share our codes

Rajesh Gupta
June 21st, 2001, 09:02 AM
Still not working.

I have written following code for ActiveX control .I have added Command button and on click of it I am displaying "parameter passed from HTML page"

Still not taking value from HTML page.
Do you have any sample application with you so that you can send me.

New Code written on ActiveX control

Option Explicit
Public ls_name As String


Public Sub Command1_Click()
MsgBox ls_name
End Sub

Public Sub UserControl_Initialize()
MsgBox ls_name
End Sub


Public Property Get GetName() As String
GetName = ls_name
End Property

Public Property Let GetName(ByVal vNewValue As String)
ls_name = vNewValue
MsgBox ls_name
End Property


Code on HTML page remains same as

<HTML>
<BODY topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0>
<OBJECT ID="project1" WIDTH=300 HEIGHT=200
CLASSID="CLSID:73310882-63E6-11D5-B368-0000F6C1326C">
<PARAM NAME="GetName" VALUE="Rajesh">
</OBJECT>
</BODY></HTML>