Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 languages in 1 file

Status
Not open for further replies.

almoes

Programmer
Jan 8, 2003
291
US
Hi!

is it possible to have an asp file with code both in javascript and vbscript? if yes how is it defined? thanxs!

alej
 
The answer to this is both yes and no.

If you want to use both Javascript and VBScript for server-side ASP scripting then the answer is definately a No.

If you wish to use both languages server-side but only need one of them to interact with things like the response object, then you can use one language for your ASP code (everything between the <% %>'s) and put the other one in <script> tags with runat="server" as an attribute to makethe script run server-side (you may want to read up more on that first though).

If you want to use one language in ASP and one language as client-side script then you have no problems.

If you want to use both as client-side scriptinf (in script tags) then you should have no problems (provided they are each in their own script tags with the langauge attributes set correctly).

So like I said, it depends on your situation. Hope I managed to cover it. I skipped a couple extreme cases (seperate files with Server.Execute/Transfer/etc) but if you need more info it can beprovided.

-T

barcode_1.gif
 
:) thanxs a lot!!! I just wanted to introde server side a function i have in vbscript into my server side javascript...and as you said, it works if i use the tag <SCRIPT LANGUAGE=VBScript RUNAT=Server> for the vbscript and <%@language.. for javascript. What it doesnt work, and thats why i posted here is haveing two different <%@language.. in the same page. But solved! thanxs!

cheers,
alej
 
From what I've read, IIS processes everything from one server-side scripting language first, then everything from the other one. That means that anything referred to by both will produce unwanted results.

The following code produced the results listed afterwards:

Code:
<%@language="vbscript"%>
<%
Dim onevariable

Response.Write "In VBScript0<br>"
%>
<script language="javascript" runat="server">
Response.Write('In Javascript<br>');
</script>

<script language="vbscript" runat="server">
Response.Write "In VBScript1<br>"
</script>

Results on the page:

In Javascript
In VBScript0
In VBScript1

Lee
 
upppssss...

my file looks like:

<%@language=javascript%>

<script language=vbscript>
myFuntction...
</script>

<%

bla

myfunction...

bla

%>

it performs the call to the vbscript function in the middle of the process and without the return value i would get an error. But it works so it seems as processing in the correct order.
 
Why are you putting your function inside script tags instead of ASP tags? Isn't that ASKING for confusion?

Lee
 
well the script tag has the runat server, i forgot to paste it...which is the same as having asp tags
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top