|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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! |
|
#2
|
|||
|
|||
|
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! |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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)! |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
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:
======================= 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! ![]() |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Instantiating Client ActiveX component |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|