473,574 Members | 3,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP: ASP JScript & VBScript interoperabilit y

How can VBScript code access JScript code variables in the same ASP page?

<SCRIPT LANGAUGE="VBScr ipt">
Dim a
a = 10
</SCRIPT>
<SCRIPT LANGUAGE="JScri pt">
Response.Write( a);
</SCRIPT>

Also, is this valid JScript code because ASP hasn't complained.

<SCRIPT LANGUAGE="JScri pt">
function Section(a, b, c, d) {
this.a = a;
this.memFunctio n = function() {
this.a = this.a + 1;
}
}
</SCRIPT>

Basically it's like JScript's way of declaring classes.

How can VBScript code create a Section object?

<SCRIPT LANGUAGE="VBScr ipt">
Dim obj
obj = new Section 'Error, says cannot find Section
obj = new Section() 'Error again
obj = new Section(1, 2, 3, 4) 'Error again
</SCRIPT>
Also, is it possible to nest <SCRIPTtag inside <% %>? Like:

<%
'Some VBScript code
Class AClass
Private a
Function b()
End Function
%>
<!-- #INCLUDE VIRTUAL="JScrip t.asp" -->
<%
End Class
%>

where JScript.asp has:

<SCRIPT LANGUAGE="JScri pt">
function Section() {
function Section2() {
}
}
</SCRIPT>

ASP didn't complain. But couldn't test whether the JScript functions Section
were member functions of the VBScript AClass.
Jun 15 '07 #1
1 3446

"Andrew Wan" <an************ @hotmail.comwro te in message
news:Or******** ******@TK2MSFTN GP04.phx.gbl...
How can VBScript code access JScript code variables in the same ASP page?

<SCRIPT LANGAUGE="VBScr ipt">
Dim a
a = 10
</SCRIPT>
<SCRIPT LANGUAGE="JScri pt">
Response.Write( a);
</SCRIPT>

Also, is this valid JScript code because ASP hasn't complained.
It won't because without a runat="server" attribute on the script element
the above is simply treated as content and sent to the client. The client
should've complained that Response is undefined.

To answer your question variables and functions declared at global scope are
accessible across the script boundaries.
>
<SCRIPT LANGUAGE="JScri pt">
function Section(a, b, c, d) {
this.a = a;
this.memFunctio n = function() {
this.a = this.a + 1;
}
}
</SCRIPT>

Basically it's like JScript's way of declaring classes.
Yeah but it's very JScript and is completely alien to VBScript.
>
How can VBScript code create a Section object?

<SCRIPT LANGUAGE="VBScr ipt">
Dim obj
obj = new Section 'Error, says cannot find Section
obj = new Section() 'Error again
obj = new Section(1, 2, 3, 4) 'Error again
</SCRIPT>
You need to create a factory function in the JScript:-

function newSection(a, b, c, d)
{
return new Section(a, b, c, d)
}

Now VBScript can use:-

Set obj = newSection(1,2, 3,4)
>

Also, is it possible to nest <SCRIPTtag inside <% %>? Like:

<%
'Some VBScript code
Class AClass
Private a
Function b()
End Function
%>
<!-- #INCLUDE VIRTUAL="JScrip t.asp" -->
<%
End Class
%>

where JScript.asp has:

<SCRIPT LANGUAGE="JScri pt">
function Section() {
function Section2() {
}
}
</SCRIPT>
No do it the other way around:-

Have a JScript.js file

then add this outside <% %:-

<script src="test.js" runat="server" language="JScri pt" ></script>

Note it only makes sense to use this a function library, in-line code isn't
much use apart from code that may help create objects.
>
ASP didn't complain. But couldn't test whether the JScript functions
Section
were member functions of the VBScript AClass.

Again the runat attribute was missing.
Jun 15 '07 #2

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

Similar topics

29
6002
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
20
5958
by: Harag | last post by:
Hi All. I'm stating out doing some web developing. I was wondering which of the server side languages should I concentrate on and learn. I Know CSS, HTML, T-SQL I can look at the client javascript code and work out what it does but I can't really write it from scratch.
4
5856
by: Harag | last post by:
Hi All I currently thinking of converting from my little knowledge of VBscript to jScript ASP. With this in mind I'm looking at my current code to see how it will convert over to Jscript. One thing I have spotted that I can't think of a way round is the ADO recordset.GetRows command.
10
2040
by: Christopher Brandsdal | last post by:
I have this string: /sites/binaer/demo/fil/Winnie-the-Pooh 1024x768.jpg If I wanted to cut everything before Winnie-the-Pooh 1024x768.jpg, how would I do this? In VBScript I could find the first "/" from the back of the sentence, and cut everything before that, but I'm not shore how to do this in JScript...
1
4213
by: JNariss | last post by:
Hello, I have created a connection to my Access database with Dreamweaver and made a simple form with 4 fields. The code behind this form was/is: <%@LANGUAGE="VBCRIPT" CODEPAGE="1252"%> <!--#include virtual="/Connections/EmployeeStatusChange.asp" --> <%
0
6726
by: Vijay | last post by:
Prep Courses for International Certifications, CSTE & CSQA & ISEB & ISTQB &Business Analyst & SOA Certifications in HYDERABAD. After receiving overwhelming response to our last 50+ batches, SPECTRAMIND SOLUTIONS now announces a new batch of Prep Courses for CSQA & CSTE& ISEB & ISTQB & Business Analyst & SOA so as to prepare you...
18
2374
by: Andrew Wan | last post by:
I have been developing web applications with ASP & Javascript for a long time. I have been using Visual Studio 2003.NET. While VS2003 is okay for intellisense of ASP & Javascript, it's still not that great. One of the cons of ASP & Javascript is that they're both interpreted, which means one has twice the amount of work to do interms of...
1
756
by: andrewwan1980 | last post by:
How can VBScript code access JScript code variables in the same ASP page? <SCRIPT LANGAUGE="VBScript"> Dim a a = 10 </SCRIPT> <SCRIPT LANGUAGE="JScript"> Response.Write(a); </SCRIPT>
1
968
by: rekhasc | last post by:
if you know the ans plz heighlite that ans 3. Interoperability classes include a. System.Runtime.InteropServices b. System.Runtime.InteropServices.CustomMarshallers c. System.Runtime.InteropServices.Expando d. All the above 4. The Component’s __________ interface helps to maintain a reference count of the number of clients using the...
0
8271
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7858
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...
0
8137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5654
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...
0
3774
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...
0
3793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2273
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1099
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...

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.