473,725 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can I use VB to contol ActiveX for .NET site?

Any suggestions on how I should handle this?

I was asked to convert a small web application that was written in classic
ASP into ASP.NET.

The original site uses some VBScript to interface with an ActiveX control,
which is contained in a CAB file.

Somehow, I have managed to use the original VBScript in a respective .NET
page, but there are several problems.

First, I need to pass into the VBScript, several .NET Session variables that
I have collected in a previous page for use by the ActiveX. I have
accomplished this by storing the variables in hidden input fields, and then
I retrieve their value from withing the VBScript. But this is such ugly
programming.

Second, in the original VBScript, the ActiveX control returns a string
(called 'Packet' in function 'citcp2_PacketR eceived') and really just stores
in in a variable. I wish to pass that string on to the next page via .NET
Session, but since the last function to execute in the page is the
aforementioned 'citcp2_PacketR eceived', and it's last inst instruction is to
submit, I do not know how to store the returned string into the .NET
Session. Normally, I would call a function from my C# script that would add
the string to the Session, but I don't think I can call a C# funtion form
with the VBScript.

Any suggestions on how I should handle this? Should I or can I convert the
VBScript into VB? I tried changing the language by simply cnging the
language name, but then I get an error that says "Object is expected". I
think it means that the VB script doesn't see the ActiveX control.

In the working VBScript, soSubmit() is called first, then
citcp2_Connecti on(address) fires and calls doSendTrade, and finally
citcp2_PacketRe ceived(Packet,b ytes_in) fires. Here is the script:


<script LANGUAGE="vbscr ipt" CODEPAGE="1252" >
dim bTrade
bTrade = false

function doSubmit()
trade_entry_ver ify.citcp2.Clos eSocket
trade_entry_ver ify.citcp2.Host Address = "IP Adress"
trade_entry_ver ify.citcp2.Port = "PortNum"
Result = trade_entry_ver ify.citcp2.Conn ectToHost
end function

Private Sub citcp2_Connecti on(address)
trade_entry_ver ify.citcp2.Send "~| Demo Screen - V7.0 -DEMO SCREE "
call doSendTrade
End Sub

Private Sub citcp2_PacketRe ceived(Packet,b ytes_in)
trade_entry_ver ify.txtTrade.va lue = Packet
//For testing - get and store packet string in hidden label
trade_entry_ver ify.packetHidde n.value = Packet
//For testing - retrieve and display value from hidden label in HTML
control to ensure proper output
trade_entry_ver ify.txtTrade2.v alue =
trade_entry_ver ify.packetHidde n.value
//Session("strPac ket")=Packet
//now add packet value to session
//HOW??
if bTrade then trade_entry_ver ify.submit
trade_entry_ver ify.citcp2.Clos eSocket
end sub

function doSendTrade()
strTradeType = document.all.tr ansTypeHidden.v alue
strOrderSpec = document.all.or derSpecHidden.v alue
strQty = document.all.qt yHidden.value
strMonth = document.all.mo nthHidden.value
strYear = document.all.ye arHidden.value
strCommodity = document.all.co mmodityHidden.v alue
strCommSymbol = document.all.co mmoditySymbolHi dden.value
strStopPrice = document.all.mo nthHidden.value
strLimitPrice = document.all.tr ansTypeHidden.v alue
strNotes = document.all.co mmoditySymbolHi dden.value
strSymbol = strCommSymbol & strMonth & strYear
sStr = "!NO, " & "D1003-79, " & date() & " @ " & time() & ", " &
strTradeType & ", " & strQty & ", " & strSymbol & ", DAY, " & strOrderSpec
If strOrderSpec = "MARKET" Then
sStr = sStr & ", "
ElseIf strOrderSpec = "STOP" Then
sStr = sStr & ", " & "999"
ElseIf strOrderSpec = "LIMIT" Then
sStr = sStr & ", " & "999"
End If
sStr = sStr & ", , , 0, 0, 0, 0, , Account , AcctNum|"
trade_entry_ver ify.txtTradeReq uest.value = sStr
bTrade = true
trade_entry_ver ify.citcp2.Send sStr
end function
</script>


In the HTML code, the AciveX is embedded as such:


<form name="trade_ent ry_verify" action="trade_e ntry_submit.asp x"
method="post">

<asp:table id="Table1" runat="server" CellPadding="3"
CellSpacing="3" />

<p>&nbsp;</p>
<p>
<input name="Cancel" type="button" id="Cancel" value="Cancel"
onClick="histor y.go(-1)">
<font color="#FFFFFF" >----------------------</font>
<input type="button" value="Place Order" onclick="doSubm it()">
</p>
<INPUT id="txtTradeReq uest" type="text" size="123" name="Text1">
<p>
<TEXTAREA id="txtTrade" name="Textarea1 " rows="2"
cols="120"></TEXTAREA>

<textarea id="txtTrade2" name="textarea" rows="2"
cols="120"></textarea>
</p>
<p>&nbsp;</p>
<OBJECT CLASSID="clsid: 5220cb21-c88d-11cf-b347-00aa00a28331"
id="Microsoft_L icensed_Class_M anager_1_0"1 VIEWASTEXT>
<PARAM NAME="LPKPath" VALUE="BCITCP.l pk">
</OBJECT>
<OBJECT id="CITCP2" height="0" width="0"
classid="clsid: CAC161FD-C2F9-4F0F-95F3-A3D4E5D465CD"
codeBase="BCITC P.CAB#version=1 ,0,0,0" VIEWASTEXT>
<PARAM NAME="_ExtentX" VALUE="873">
<PARAM NAME="_ExtentY" VALUE="847">
</OBJECT>

<!--get and store session variables from codebehind for use in
VBScript-->
<input type="hidden" id="transTypeHi dden" runat="server" >
<input type="hidden" id="qtyHidden" runat="server" >
<input type="hidden" id="yearHidden " runat="server" >
<input type="hidden" id="monthHidden " runat="server" >
<input type="hidden" id="orderSpecHi dden" runat="server" >
<input type="hidden" id="commoditySy mbolHidden" runat="server">
<input type="hidden" id="commodityHi dden" runat="server" >
<input type="hidden" id="stopPriceHi dden" runat="server" >
<input type="hidden" id="limitPriceH idden" runat="server" >
<input type="hidden" id="notesHidden " runat="server" >
<!-- get and store returned packet from CITCP2 object Doesn't work-->
<!-- <input type="text" id="packetHidde n" runat="server">-->
</form>

Dec 9 '05 #1
1 1185

"Frank" <fk******@pfmai l.com> wrote in message
news:eO******** ******@TK2MSFTN GP14.phx.gbl...
Any suggestions on how I should handle this?

I was asked to convert a small web application that was written in classic
ASP into ASP.NET.

The original site uses some VBScript to interface with an ActiveX control,
which is contained in a CAB file.

Somehow, I have managed to use the original VBScript in a respective .NET
page, but there are several problems.

First, I need to pass into the VBScript, several .NET Session variables
that
I have collected in a previous page for use by the ActiveX. I have
accomplished this by storing the variables in hidden input fields, and
then
I retrieve their value from withing the VBScript. But this is such ugly
programming.

Second, in the original VBScript, the ActiveX control returns a string
(called 'Packet' in function 'citcp2_PacketR eceived') and really just
stores
in in a variable. I wish to pass that string on to the next page via .NET
Session, but since the last function to execute in the page is the
aforementioned 'citcp2_PacketR eceived', and it's last inst instruction is
to
submit, I do not know how to store the returned string into the .NET
Session. Normally, I would call a function from my C# script that would
add
the string to the Session, but I don't think I can call a C# funtion form
with the VBScript.

Any suggestions on how I should handle this? Should I or can I convert the
VBScript into VB? I tried changing the language by simply cnging the
language name, but then I get an error that says "Object is expected". I
think it means that the VB script doesn't see the ActiveX control.

In the working VBScript, soSubmit() is called first, then
citcp2_Connecti on(address) fires and calls doSendTrade, and finally
citcp2_PacketRe ceived(Packet,b ytes_in) fires. Here is the script:


<script LANGUAGE="vbscr ipt" CODEPAGE="1252" >
dim bTrade
bTrade = false

function doSubmit()
trade_entry_ver ify.citcp2.Clos eSocket
trade_entry_ver ify.citcp2.Host Address = "IP Adress"
trade_entry_ver ify.citcp2.Port = "PortNum"
Result = trade_entry_ver ify.citcp2.Conn ectToHost
end function

Private Sub citcp2_Connecti on(address)
trade_entry_ver ify.citcp2.Send "~| Demo Screen - V7.0 -DEMO SCREE "
call doSendTrade
End Sub

Private Sub citcp2_PacketRe ceived(Packet,b ytes_in)
trade_entry_ver ify.txtTrade.va lue = Packet
//For testing - get and store packet string in hidden label
trade_entry_ver ify.packetHidde n.value = Packet
//For testing - retrieve and display value from hidden label in HTML
control to ensure proper output
trade_entry_ver ify.txtTrade2.v alue =
trade_entry_ver ify.packetHidde n.value
//Session("strPac ket")=Packet
//now add packet value to session
//HOW??
if bTrade then trade_entry_ver ify.submit
trade_entry_ver ify.citcp2.Clos eSocket
end sub

function doSendTrade()
strTradeType = document.all.tr ansTypeHidden.v alue
strOrderSpec = document.all.or derSpecHidden.v alue
strQty = document.all.qt yHidden.value
strMonth = document.all.mo nthHidden.value
strYear = document.all.ye arHidden.value
strCommodity = document.all.co mmodityHidden.v alue
strCommSymbol = document.all.co mmoditySymbolHi dden.value
strStopPrice = document.all.mo nthHidden.value
strLimitPrice = document.all.tr ansTypeHidden.v alue
strNotes = document.all.co mmoditySymbolHi dden.value
strSymbol = strCommSymbol & strMonth & strYear
sStr = "!NO, " & "D1003-79, " & date() & " @ " & time() & ", " &
strTradeType & ", " & strQty & ", " & strSymbol & ", DAY, " & strOrderSpec
If strOrderSpec = "MARKET" Then
sStr = sStr & ", "
ElseIf strOrderSpec = "STOP" Then
sStr = sStr & ", " & "999"
ElseIf strOrderSpec = "LIMIT" Then
sStr = sStr & ", " & "999"
End If
sStr = sStr & ", , , 0, 0, 0, 0, , Account , AcctNum|"
trade_entry_ver ify.txtTradeReq uest.value = sStr
bTrade = true
trade_entry_ver ify.citcp2.Send sStr
end function
</script>


In the HTML code, the AciveX is embedded as such:


<form name="trade_ent ry_verify" action="trade_e ntry_submit.asp x"
method="post">

<asp:table id="Table1" runat="server" CellPadding="3"
CellSpacing="3" />

<p>&nbsp;</p>
<p>
<input name="Cancel" type="button" id="Cancel" value="Cancel"
onClick="histor y.go(-1)">
<font color="#FFFFFF" >----------------------</font>
<input type="button" value="Place Order" onclick="doSubm it()">
</p>
<INPUT id="txtTradeReq uest" type="text" size="123"
name="Text1">
<p>
<TEXTAREA id="txtTrade" name="Textarea1 " rows="2"
cols="120"></TEXTAREA>

<textarea id="txtTrade2" name="textarea" rows="2"
cols="120"></textarea>
</p>
<p>&nbsp;</p>
<OBJECT CLASSID="clsid: 5220cb21-c88d-11cf-b347-00aa00a28331"
id="Microsoft_L icensed_Class_M anager_1_0"1 VIEWASTEXT>
<PARAM NAME="LPKPath" VALUE="BCITCP.l pk">
</OBJECT>
<OBJECT id="CITCP2" height="0" width="0"
classid="clsid: CAC161FD-C2F9-4F0F-95F3-A3D4E5D465CD"
codeBase="BCITC P.CAB#version=1 ,0,0,0" VIEWASTEXT>
<PARAM NAME="_ExtentX" VALUE="873">
<PARAM NAME="_ExtentY" VALUE="847">
</OBJECT>

<!--get and store session variables from codebehind for use in
VBScript-->
<input type="hidden" id="transTypeHi dden" runat="server" >
<input type="hidden" id="qtyHidden" runat="server" >
<input type="hidden" id="yearHidden " runat="server" >
<input type="hidden" id="monthHidden " runat="server" >
<input type="hidden" id="orderSpecHi dden" runat="server" >
<input type="hidden" id="commoditySy mbolHidden" runat="server">
<input type="hidden" id="commodityHi dden" runat="server" >
<input type="hidden" id="stopPriceHi dden" runat="server" >
<input type="hidden" id="limitPriceH idden" runat="server" >
<input type="hidden" id="notesHidden " runat="server" >
<!-- get and store returned packet from CITCP2 object Doesn't work-->
<!-- <input type="text" id="packetHidde n" runat="server">-->
</form>


Your questions don't relate to C#, please post to the more appropriate
microsoft.publi c.dotnet.framew ork.aspnet NG

Willy.
Dec 9 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5993
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is a ocx developed my me use vc6,this ocx works fine in wxpython. but you can see i only change this ocx with a new DICOM ocx and set up eventClass,
12
2589
by: A.M. | last post by:
Hi at all, how can I do to insert into a HTML page a file .txt stored in the same directory of the server where is the html file that must display the text file.txt? Thank you very much P.Pietro
3
2959
by: Steve Richter | last post by:
running a simple vbscript in an .htm page that starts excel and loads the spreadsheet with the contents of a <table> ... </table> getting an "Error: ActiveX component cant create object. Excel.Application" error. <script language="vbscript"> Sub TableToExcel_onclick Dim sHTML, oExcel, oBook sHTML = document.all.item("DataGrid1").outerHTML
0
1583
by: Frank | last post by:
Any suggestions on how I should handle this? I was asked to convert a small web application that was written in classic ASP into ASP.NET. The original site uses some VBScript to interface with an ActiveX control, which is contained in a CAB file. Somehow, I have managed to use the original VBScript in a respective .NET page, but there are several problems.
3
315
by: Peter | last post by:
ASP.NET 1.1 + IE I have the following code this.butCreateLetter.Attributes.Add("onClick", "return CreateLetter();"); This code Excecutes the following JScript function CreateLetter() {
7
4396
by: Jarod_24 | last post by:
I just downloaded a activex control that was written in C# and tried to view it on my PDA's Internet Explorer. At my regular PC it displayed just fine, but nothing showed up on the pda. Do ActiveX controls that are to be used by a pda need to be written in the ..net compact framework, or am i missing something else here? i have a HP iPaq 2490 with Windows Mobile Premium installed While i'm at it; does a activex control allow you to...
1
1189
by: stephen | last post by:
Hi, Can we have a tab contol on a webform just like windows application? if yes, can you please point me to the article. Thanks, Stephen
1
2232
by: Jayender | last post by:
Hi, I have an ActiveX control (to display the Images),I have added the reference of that in my web based applicaton .and added the ocx in my tool bar , but the viewer (activex component- ocx ) is disabled , but i tried this in Window based application, and it works great , but i need to do it in Web based applicaion , is there anything i need to add for making that to enable so that i can drag and place it in my web form ? waiting for...
7
5816
by: Artie | last post by:
Hi, Our team have a web project which includes some C# ActiveX DLLs. On some developers' PCs, the code which calls methods in the ActiveX dll is succesful - no exceptions. On other PCs, the ActiveX control doesn't even seem to get loaded. (On the failing machines, if we try and debug down to where the ActiveX DLL method is invoked, both Visual Studio and IE hang.)
1
986
by: Oriane | last post by:
Hi there, I've built an Asp.Net web site which launchs a ActiveX executable. When I launch this activeX from a session, with the session account, an icon associated with this activeX is displayed in the notification zone of the taskbar. Then I can display the contextual menu of this activeX. Now when I load my we site, of course nothing appears in the toolbar since the activeX is started "in the background", and I need a way to make it...
0
8750
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8091
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6701
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6010
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4509
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2154
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.