Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old November 25th, 2003, 07:24 PM
jimbusse jimbusse is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: San Francisco
Posts: 4 jimbusse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Instantiating Client ActiveX component

I have developed an ASP that contains a VBScript subroutine. This function instantiaties an ActiveX component using it's class ID. the code works fine when the component is registered on the Server.

How do I get VB script to instantiate this already-registered component on the Client? The app's installation program copies the DLL and correctly registers it on the client, but I can't seem to use that one, I can only use the one on the server. I've tried many times, but the page seems to need a Server.CreateObject() or a CreateObject function, which only gets the component registered on the server (If I don't register it, I get an "object expected" error).

I can do this using Try/Catch in Javascript, but I can't get it to work in VBScript.

Any assistance would be appreciated.

a kind of code snippit:

<head>
<object id=ActiveXControl CLSID="the class id" VIEWASTEXT>
</object>
<script language = "vbscript">
<%
sub aVBSsubroutine
dim avariable
' Set ActiveXControl = CreateObject("ActiveXControlName.Name")
avariable = ActiveXControl.DoFunction(stuff)
etc

This will give the "object expected error, and when I uncomment the Set line, I can't get the client's ActiveX control.

Thanks!

Reply With Quote
  #2  
Old December 1st, 2003, 09:46 PM
justsml justsml is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: london,denver,positano,paris
Posts: 34 justsml User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Server side code cannot access client code (raw html to be sent)

Server side code cannot access client code (raw html to be sent).
You cannot execute commands on an object that is going to be sent to the client. ( i hope that makes sense. I am kinda tired )

anyway ... as a quick fix ... you might get away with something like this:
Code:
<head>
<object id=ActiveXControl CLSID="the class id" VIEWASTEXT>
</object>
<script language = "vbscript">
'NOTE: I REMOVED THE SERVER-SIDE PROCESSING TAG - YOU MUST REMOVE IT'S END TAG!!!!!!!!!!!!!!!!!
sub aVBSsubroutine
dim avariable
' Set ActiveXControl = CreateObject("ActiveXControlName.Name")
avariable = ActiveXControl.DoFunction(stuff)


hope that helps
__________________
Dan!

Reply With Quote
  #3  
Old December 2nd, 2003, 12:58 PM
jimbusse jimbusse is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: San Francisco
Posts: 4 jimbusse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your reply, Dan. Yes, it made sense. I had already tried an experiment where I created a subroutine that didn't use the
<%
%>
(run at server) controls, and failed because I was unable to transfer data between the calling routine or the called routine. I may not have been doing it correctly, but I tried every combination I could think of using variables and session variables. Basically, the output of the ActiveX control needs to transfer its created block of data to the server. I would usually get "type mismatch" errors when I would get all the compile errors out.

To work-around the problem, I created a Javascript page that has a message box. I call the javascript page, it instantiates the Client's ActiveX control, puts the output in a message box, passes it back to my VBScript page, I strip out the message box overhead glop, and I have the ActiveX control data back again.

Considering Microsoft's effort on COM, I just think there should be an easy way of launching a Client-based ActiveX component from a VisualBasic script on a server. I guess there isn't. Lots of people probably smarter than I have viewed this and have no suggestions.

Thanks again.

Jim

Reply With Quote
  #4  
Old December 2nd, 2003, 01:44 PM
justsml justsml is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: london,denver,positano,paris
Posts: 34 justsml User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Fun with Browser Based ActiveX Apps!

Hi jimbusse,
I wrote a VB ActiveX App that has been installed on over 12,000 computers! I think that I have ran into just about every issue (well, at least I FEEL that way) that can come up during ActiveX application's use, deployment and development.

Anyway, is this control supposed to run as an object on the SERVER and/or CLIENT...

Does this control have a (real) UI.

Do you want the control, if it runs exclusively on the CLIENT, to post data back to the server silently.

(i am kinda guessing about what your needs are ... )

What is the required SERVER function (basically)?

What is the required CLIENT function (basically)?

If you can answer those questions it'll help me help you (a lot)!

Reply With Quote
  #5  
Old December 3rd, 2003, 05:28 PM
jimbusse jimbusse is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: San Francisco
Posts: 4 jimbusse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi, Dan!

I really appreciate your reply, and expertise. My expertise with VBScript is limited. Please ask me a BIOS question sometime!

I need for the control to run as an object on the client. It does this, I've tested with Javascript. The output of the control was type Variant (I thought VBScript only supported type variant). It had to be changed to type string to get the Javascript page to work. So I have 2 versions, one for Javascript where the binary output data is changed to string, and one for VBScript where the binary output data is type variant. Basically, it's just a binary block of data.

The object runs fine on the server. Sigh. When I create a simple VB application for the client, the object runs fine on the client.

There is no UI for the control. It simply has a couple of methods, one to capture the block, and one to save the block. Both methods work fine in VBScript on the server. Both methods work fine in Javascript on the client. I didn't try the Javascript version on the server, my guess is that it works fine, because the only change was the output type.

It's supposed to work like this: The server ASP page askes the client a question, and with a button press, instantiates the ActiveX control. The client responds to the question, and the ActiveX captures this response and will return this block to the server. The server will then process this block and save it in a local server-based file. In VBS, it's 2 lines of code (what can go wrong?)

Dim outputblock
outputblock = ActiveXObject.Capture(some parameters)

Where outputblock is type variant, and the ActiveXObject.Capture function returns type variant. In Javascript it's similar but the javascript version has to convert the string output type back to variant output type so the server can process and save the block. (As well as using Try{} Catch{} )

I'm not sure what you mean "silently". It shouldn't take too long, the blocks will be <50K bytes, so it's OK if the client "freezes" during the transfer. (That's another problem, the Javascript string version takes minutes to transfer).

with all the tags eliminated for clarity, the (pseudo)code should be as simple as:

(<object ID=ActiveXAction CLASSID="clsid:xxxxx"></object>
sub runonclient
outputblock = ActiveXAction.Capture(some parameters)
'messagebox is defined on the form
messagebox = outputblock
end sub

<%
sub runonserver
runonclient
...strip the message box overhead and process and save outputblock....
end sub
%>

Now I'm trying to convert over to one page that has no <% %> tags, and just let that page run at client, then have it post the data block to the processing function on the server using the messagebox. I'm open to all suggestions because I don't want to leave the variant-to-string conversion in, if I can help it. It seems way slow.

Jim

Reply With Quote
  #6  
Old December 3rd, 2003, 08:00 PM
justsml justsml is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: london,denver,positano,paris
Posts: 34 justsml User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Hi Mr. Jim!

Hi Jim,
Hmm ... i don't think I have any BIOS questions, but thanks for the offer ....

Anyway, look at your line of psudo-code that calls "runonclient" from inside the "runonserver" sub ... you cannot do this ..... the "runonclient" subroutine can only be called from client-side code ... your compiled ActiveX should handle talking to your server.

Quote:
(<object ID=ActiveXAction CLASSID="clsid:xxxxx"></object>
sub runonclient
outputblock = ActiveXAction.Capture(some parameters)
'messagebox is defined on the form
messagebox = outputblock
end sub

<%
sub runonserver
'DAN'S NOTE: "runonclient" cannot be called in server side code.
runonclient
...strip the message box overhead and process and save outputblock....
end sub
%>


=======================
You can call runonclient like this:
Code:
<input type="button" onclick="runonclient" value="Run client-side code" />

OR inside a client-side script block.
Code:
<script language="vbscript">
Private Sub TalkToTheActiveX()
MsgBox "Running client side sub..."
Call runonclient()
MsgBox "DONE running client side sub..."
End Sub
</script>

....
I might be assuming too much or too little here... Oh well, I'll help you sooner or later!

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Instantiating Client ActiveX component


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway