Title: ASP I
1ASP I
- Topics
- --What is ASP???? http//searchwin2000.techtarget.
com/sDefinition/0,,sid1_gci213787,00.html - --VBScript
- --OBJECTS RESPONSE WRITE
- --Variables
2ASP- All Inclusive Tutorial
- General ASP Tutorial
- http//www.aspronline.com/learn
- An ASP Tutorial Specific to Assignments
- http//webwizguide.com/asp/tutorials/connecting_to
_a_database.asp -
3 4Static Dynamic(ASP)
5ASP
- Server-side scripting language, lets you choose
the syntax you wish to use for development. - Two most popular scripting languages for ASP are
VBScript and Jscript - PerlScript is another less popular option
6ASP
- To set what scripting language you want to use,
at the top of your ASP programs, you need to add
a single line of code - lt_at_ LANGUAGEVBSCRIPT gt
- VBScript is more widely used
- JScripts syntax is much like JavaScripts.
7ASP OBJECTSWhat is an object???
- Response Object
- One of the most important objects in ASP.
- It is the object which communicates between the
server and the output which is sent to the
client. - To write an ASP page, all you need to do is write
a standard HTML page, putting in the Active
Server Pages script where needed. - Active Server Pages script is denoted by the text
between lts and gts.
8Response Object
- To send ASP to the client, you need to use the
Response Object. - The method of the Response Object which sends
data to the client is the Write method. - Unlike an HTML page which is sent directly to the
client, the ASP page passes through the servers
ASP.DLL. - What is DLL???? http//searchwin2000.techtarget.co
m/sDefinition/0,,sid1_gci213902,00.html
9The Response Object
- Example
- lt_at_ LANGUAGEVBSCRIPT gt
- ltHTMLgt
- ltBODYgt
- lt Response.Write (Hello, World!) gt
- lt/BODYgt
- lt/HTMLgt
10Variables in ASP
- All variables are of type Variant. You dont
have to declare if your variable is an integer,
string, or object.
lt_at_ LANGUAGEVBSCRIPT gt lt
Declare a variable. A single tick denotes a
comment in VBSscript Dim MyName
To declare a variable, you just put the
word Dim in front of the variable name. Lets
assign something to MyName MyName Scott
Mitchell
11Variables in ASP
- Lets create some more variables
- Dim Age, Pi
- Age 20
- Pi 3.14159
Since all variables are variants, we
can Reassign values. (Bad coding,
though!) MyName 45 Pi Age Age Yellow
Schoolbus!
gt
12Variables in ASP
- To print out the variables, you could simply do a
Response.Write.
- Example
- lt_at_ LANGUAGEVBSCRIPT gt
- lt
Declare a variable. A single tick denotes a
comment in VBScript Dim MyName MyName Scott
Mitchell
13Variables in ASP
- Print out MyName
- Response.Write (MyName)
To concatonate strings in VBScript, use
the ampersand Response.Write(My name is
MyName) gt
14Variables in ASP
- You can explicitly cast the type of a variable
when you assign to it.(This is good programming
technique)
- Example of CStr Cint)
- gt_at_ LANGUAGEVBSCRIPT gt
- gt
- Declare the variable MyName.
- Dim MyName
- Explicitly make MyName a string
- MyName CStr(Scott Mitchell)
15Variables in ASP
- Dim Age, Pi
- Explicitly make Age an integer
- Age Cint (20)
- Explicitly make Pi a floating point
- value
- Pi CDbl (3.14159)
- gt
16ADO WEB SITE
- ADO
- http//www.w3schools.com/ado/default.asp
17ASP SCRIPT
lthtmlgt ltbodygt ltform action"demo_simpleform.asp"
method"post"gt Your name ltinput type"text"
name"fname" size"20"gt ltinput type"submit"
value"Submit"gt lt/formgt lt dim fname fnameRequest
.Form("fname") If fnameltgt"" Then
Response.Write("Hello " fname "!ltbr /gt")
Response.Write("How are you today?") End
If gt lt/bodygt lt/htmlgt