2

Inside a classic asp page, I'm told that you can use vbscript or jscript. And jscript is just javascript.

So I'm not sure what the difference is between Response.Write, Response.Write(), response.write(), and document.write()

Does the capitalization matter, and sometimes I seem to see no parentheses after the method name, and sometimes I do. It's all devolving into a mess inside my newbie head.

If I'm writing classic asp using JScript (and not VBScript), should everything inside <% %> be considered javascript, just on the server side?

Prior to classic asp, I was sure that javascript was a client-side scripting language only.

user798719
  • 9,619
  • 25
  • 84
  • 123

3 Answers3

0

You can use VBScript or JScript as your language when writing classic ASP server-side code.

From Wikipedia:

JScript is Microsoft's implementation of the ECMAScript standard that is used in Microsoft's Internet Explorer.

You can also use it in classic ASP, and it has some additional objects available (Response, Request, Application, Session, etc) so that you can do server-side web programming.

If I was required to write classic ASP, I would definitely choose JScript. Each language has its own syntax requirements that you will need to learn whichever you choose.

document.write() is not used server-side to send data back to the client, you always use the Response object for that.

If I'm writing classic asp using JScript (and not VBScript), should everything inside <% %>be considered javascript, just on the server side?

Depends on the context—generally the syntax is the same. Stick with Microsoft's JScript documentation and you'll be fine.

Cœur
  • 37,241
  • 25
  • 195
  • 267
D'Arcy Rittich
  • 167,292
  • 40
  • 290
  • 283
0

So I'm not sure what the difference is between Response.Write, Response.Write(), response.write(), and document.write()

If they all work, then I would suggest to just pick one and go with it. Though, I remember reading that you should not use document on the server side.

No, you don't have to worry about the capitalization in vbscript. It really comes down to personal preference. I like to use Response.Write() myself, but I've seen response.write littered throughout source code as well.

Methods with parentheses vs methods without parentheses. The difference is the type of method. Vbscript supports sub and function methods. A sub is used when no data is meant to be returned and a function is used when data is to be returned. A sub method takes it's parameters without parentheses (the server will complain if you try to call a sub with parentheses and more than one parameter). A function takes it's parameters with parentheses. Don't ask me why the creators chose to do it this way, it annoys the heck out of me.

JavaScript can be used on the server with classic asp. It actually can come in handy if you are wanting to pass JSON around https://stackoverflow.com/a/1021848/296889.

Community
  • 1
  • 1
jeremysawesome
  • 7,033
  • 5
  • 33
  • 37
-2

Yes capitalization does matter. VB tends to lean towards pascal casing for methods, so .Write() would be correct in vb. But .write() would be correct in javascript. If it is a predefined function that is.

No everything inside the <% %> tags would not be considered javascript, it would be considered asp.

bluegman991
  • 707
  • 4
  • 9
  • There actually are ways to run javascript on the server... it's just a programming language. http://www.codeproject.com/Articles/4271/Sharing-JavaScript-source-code-between-client-side – jeremysawesome Mar 22 '12 at 03:10
  • 1
    ASP is not its own language. JavaScript can be executed anywhere that there is a compatible interpreter (including class ASP). – Tim M. Mar 22 '12 at 03:13
  • -1: ASP is not a language. The languages are VBScript and JScript, the latter which you seem unaware of. – D'Arcy Rittich Mar 22 '12 at 03:21