Home Tutorials IT Jobs Source Codes Certifications Discussion Forum
  Python Tutorials
Introduction
ASP - Setup
ASP - Running
ASP - First Script
Syntax
ASP - VBScript
ASP - Javascript
ASP - Operators
If Statement
Select
Variable
Array
Session
Cookies
String
Forms
Forms Get
Forms Post
Email Form
ASP Object
ASP Components
ASP Comments
Special Characters
DLL
ADO
ASP File
ASP Date
   IT Jobs
Software Jobs
Networking Jobs
   Model Question Papers
BE Computer Science
MCA
BCA
Others
 
   

ASP Programming - VBScript

As was mentioned in the last lesson, ASP uses VBScript as its default scripting language. VBScript is similar to Javascript, a client side programming language used to add functionality through the <script> tag.

Read the following paragraph carefully!

VBScript, when used to program ASP converts it to server side scripting. Any given web page could be created from a combination of server side and client side scripting. The confusing part is this: You must use these client side scripting languages (Javascript, VBScript, etc) to program in ASP!

Below we have a simple ASP script programmed in VBScript and includes the necessary HTML as well. This is only server-side scripting.

Server Side ASP Code using VBScript:

<html>
<body>
<% 
Dim myString
myString = Date()
Response.Write("The date is: " & myString)
%>
</body>
</html>

Display:

The date is: 3/19/2008


If you already know VBScript or Visual Basic programming then you'll recognize Dim as Dimension, which is used to "dimension" variables. It is a good programming practice to "dimension" all your variables before you use them, as we did with myString in the above example.

Now that we have our ASP Code working, say that we wanted to use our ASP code along with some client side Javascript code. To keep it simple we are just going to use the Javascript write function and have our ASP Code fill in the Date. All the Javascript client code is in the default color, but ASP Server Side Code is in Red.

ASP Code w/ VBScript and Client Side Javascript Code:

<script>
document.write("The date is:<% 
Dim myString
myString = Date()
Response.Write(myString)
%>")
</script>

Display:

The date is: 3/19/2008

If you just want to program in ASP you can disregard the above example if you find it confusing. Just remember that you can have client-side Javascript code and server-side ASP/VBScript code included in an ASP generated web page!

 

<< Previous | Next >>

Home  |  About us  | Privacy  |  Disclaimer  |  Contact us |  Advertise with us | Our Link Partners
All Rights Reserved 2009, CodeTeller.com