Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 19th, 2004, 11:04 AM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Custom UserControl + ASP


I have a problem with incorporating custom activeX controls into
web pages (ASP). For example if I (in VB) build a simple control
named MyUserControl that contains only the text box Text1 and the
code

Public Property Get MyText() As String
    MyText = Text1.Text
End Property


Public Property Let MyText(ByVal New_MyText As String)
    Text1.Text = New_MyText
End Property

I then set the controls public property to 'True' and compile it to the file MyUserControl.ocx. If I now open a new VB project I can see
that MyUserControl is indeed in the components list and can be added to the tool box. This works fine and I can add an instance of the control 'MyUserControl1' to a form and in code assign a value to it

Me.MyUserControl1.MyText = "XXXXXXXX"

If I instead in Interdev create an ASP then I can see MyUserControl in the components list and I can add it to the page. However if I try
to run the script

function button1_onclick() {
MyUserControl1.MyText = "XXXXXXXX"
}

then I get the message: 'object doesn't support this property or method'. What is wrong? Can somebody help me with this?

                            ThanX, Ernst

  #2 (permalink)  
Old February 19th, 2004, 12:12 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Congratulations!!! You have just posted the 10,000th message here on P2P. You have won a ... no, wait. I guess you're more interested in an answer to your question ;) (Look at the querystring for this post)

How do you add your control to the page? With what code? Is the control accessible by client-side JavaScript? That is, did you add a client control?

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #3 (permalink)  
Old February 20th, 2004, 12:05 PM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My goal is to be able to add any custom made ActiveX control
to an ASP. I have used VB6 to make the control and Visual
InterDev to design the web page. The resulting code is:

<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function button1_onclick() {
    UserControlX1.MyText = "XXXXXXX"
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<P>

<OBJECT id=MyUserControl1 style="WIDTH: 78px; HEIGHT: 49px"
classid=clsid:16D06D6E-63BA-11D8-BF80-00D0B7AA5636 VIEWASTEXT>
<PARAM NAME="_ExtentX" VALUE="2064">
<PARAM NAME="_ExtentY" VALUE="1296"></OBJECT>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;

<INPUT id=button1 style="WIDTH: 56px; HEIGHT: 24px"
      type=button size=19 value=Button name=button1
          LANGUAGE=javascript onclick="return button1_onclick()"></P>

</BODY>
</HTML>


Note that I have not included any server script here, only client
script. This is just an attempt to be able to make the ActiveX
control work. It does work when run on a VB form but why not here?
Is there any registry problems? Any suggestions?

                                       Ernst.

  #4 (permalink)  
Old February 20th, 2004, 12:15 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Client side ActiveX in the browser is not really my cup of tea. However, I could make a simple example work by following these steps:

1. Created an ocx in VB6. Added a public property.
2. Compiled the project and build the ocx
3. Used the Package & Deployment Wizard to create a Web Setup package.

This last step resulted in a .CAB file and an HTML file with this code:

<OBJECT ID="UserControl1"
CLASSID="CLSID:80DA4710-45D0-4ABE-B672-08FDF045F4C1"
CODEBASE="Project1.CAB#version=1,0,0,0">
</OBJECT>

Notice that the CODEBASE is referencing the .Cab file. Maybe you're missing this step. I can imagine the browser is unable to determine where to get the .ocx file, especially when you request the page over the Internet. For the client, 80DA4710-45D0-4ABE-B672-08FDF045F4C1 doesn't mean anything unless you have it point to a physical file somewhere. The Codebase should point the client to the correct Cab which it can then download.

HtH,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #5 (permalink)  
Old February 20th, 2004, 01:57 PM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, but I still can't make it work. (and it is not due to
the typo in line 8 in my script - UserControlX1 should be MyUserControl1)
I guess I try again tomorrow.....

                                              Ernst

  #6 (permalink)  
Old February 20th, 2004, 02:00 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Did you create a .Cab file with the wizard? How does the <object> tag look like that the wizard generated?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #7 (permalink)  
Old February 21st, 2004, 01:45 PM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes I created a .Cab file and here is its <object> tag:

<OBJECT id=MyUserControl style="LEFT: 0px;
TOP: 0px" codeBase=prjCtrlX.CAB#version=1,0,0,0
    classid=CLSID:16D06D6E-63BA-11D8-BF80-00D0B7AA5636
    VIEWASTEXT>
    <PARAM NAME="_ExtentX" VALUE="2064">
    <PARAM NAME="_ExtentY" VALUE="767"></OBJECT>

I then pasted this into my ASP that also contains the 'button1'
When I in button1's event code type MyUserControl and then a . it automatically pops up a 'tool tip box' containing the property 'MyText' so the system seems to recognize MyUserControl as an object with the MyText property. Could it be problems with the location of the package? It now sits in the same folder as the ASP.
I have also unziped the .Cab file. It stil doesn't work....

                                              Ernst


  #8 (permalink)  
Old February 22nd, 2004, 05:32 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The only thing I can think of that is causing this problem is security settings. Is the browser allowed to execute code in the control?
I tested my setup locally, so the browser had enough rights (I did get a pop up though, as I setup IE to pop up a warning with Active X controls). Maybe IE is locking access, or your firewall / security system blocks it.

Are you running this locally? Did you create the ocx on the same computer as the one you use for testing?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #9 (permalink)  
Old February 26th, 2004, 01:48 PM
Registered User
 
Join Date: Sep 2003
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes it was the server settings that was the problem.
After changing default address from "localhost"
to the servers IP address it now works!
Thank you for helping.

                             Ernst.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom HTTP 404 Problem w/ASP to ASP.NET kwilliams ASP.NET 2.0 Professional 7 November 26th, 2007 04:17 PM
asp.net 2 custom membership provider andyw ASP.NET 2.0 Professional 24 September 6th, 2006 08:31 AM
Event in an ASP.NET 2 usercontrol bmains ASP.NET 2.0 Basics 1 February 25th, 2005 03:28 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.