473,415 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,415 software developers and data experts.

HELP: ASP JScript & VBScript interoperability

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>

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

<SCRIPT LANGUAGE="JScript">
function Section(a, b, c, d) {
this.a = a;
this.memFunction = 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="VBScript">
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="JScript.asp" -->
<%
End Class
%>

where JScript.asp has:

<SCRIPT LANGUAGE="JScript">
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 3421

"Andrew Wan" <an************@hotmail.comwrote in message
news:Or**************@TK2MSFTNGP04.phx.gbl...
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>

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="JScript">
function Section(a, b, c, d) {
this.a = a;
this.memFunction = 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="VBScript">
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="JScript.asp" -->
<%
End Class
%>

where JScript.asp has:

<SCRIPT LANGUAGE="JScript">
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="JScript" ></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
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
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...
4
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. ...
10
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...
1
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"%>...
0
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, ...
18
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...
1
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
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...
0
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...

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.