473,324 Members | 2,456 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,324 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 3415

"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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.