Writing JavaScript in ASP classic

16,778

ASP is a technology, NOT a language. You can write your ASP pages in any language which is registered as a Scripting Engine. So you can use VBScript, Javascript, Perl, ... if there is a scripting engine registered in your server, you can use it.

How? Like this!

<%@ Language= "Javascript" %> 
<% 
  var message = 'This is my message: ';
  for (var i = 0, endI = 10 ; i < endI ; i++){ 
      Response.Write( message + ' ' + i + '<br>' ) ;
  };
%> 
Share:
16,778
Zephram
Author by

Zephram

Updated on June 15, 2022

Comments

  • Zephram
    Zephram almost 2 years

    Is it possible (and how if so) to write JavaScript code directly into an ASP classic file?

    I want to create validation functions inside an ASP classic file.

  • Zephram
    Zephram over 10 years
    This is exactly what I was looking for.
  • Zephram
    Zephram over 10 years
    Can I jump between VBscript and JavaScript and how?
  • MC ND
    MC ND over 10 years
    You SHOULD NOT use the two (or more) at the same time in the same page. Lot of reasons for a comment. Try and you will see. BUT, if you keep each page with only one language, you can use Server.Execute or Server.Transfer to organize execution. AND what you SHOULD do with multiple languages is encapsulate code in .WSC (windows script components).
  • Tracker1
    Tracker1 over 8 years
    @Zephram from a JS page, or VB page, you can include a <script runat="server" language="..." src="..."></script> that will load any language installed for the scripting runtime (VBScript and JScript by default, but there are/were other options) ... the only big issue in JScript is COM based collections are awkward to deal with.