Internet Systems Design:
Technologies for Modern Information Systems

Example ASP Code

Example 1

<html>
<head>
<title>ASP Example 1</title>
</head>
<body>
<p>This page was last refreshed on <%= Date %> </p>
<p>Now it is <%= Now %> </p>
</body>
</html>
 

Example 2 HTML Page



<html>
<head>
<title>ASP Example 2</title>
</head>
<body>
<form method="POST" action="resultofexample2.asp">
<p>A= <input type="text" name="ValueofA" size="20"></p>
<p>B= <input type="text" name="ValueofB" size="20"></p>
<p><input type="submit" value="Calculate" name="B1"></p>
</form>
</body>
</html>
 

Example 2 ASP Page

<html>
<head>
<title>Example 2 ASP Page</title>
</head>
<body>
<p>Example Page <%@ language="vbscript" %>
<% dim A, B
A=Request.form("ValueofA")
B=Request.form("ValueofB") %> </p>
<p>A+B= <%= eval(A)+eval(B) %> </p>
<p>A-B= <%= eval(A)-eval(B) %> </p>
<p>A*B= <%= eval(A)*eval(B) %> </p>
</body>
</html>

Example 3 HTML Page

<form method="Post" action="Find.asp">

<p> <select name = "item" method ="post" size ="1">
<option selected value="Gum">Gum</option>
<option selected value="Suckers">Suckers</option>
<option selected value="Taffy">Taffy</option>
<option selected value="Skittles">Skittles</option>
<option selected value="M&Ms">M&Ms</option>
<option selected value="Lifesavers">Lifesavers</option>
<option selected value="Snickers">Snickers</option>
</select><input type="submit" value="Tell me the price">
</p>
</form>
 

 

Example 3 ASP Page

<%@ LANGUAGE='VBSCRIPT'%>
<html>

<head>

</head>

<body>
<%
dim price
Set MyConn = Server.CreateObject("ADODB.Connection")
set RS = Server.CreateObject("ADODB.Recordset")
MyConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath
("Candy.mdb")

item = Request.form("item")

Set RS = MyConn.execute("Select * from Products where Candy = '" & item & "'")

if RS.Eof then
Price = ""
else
Price = RS("Price")
End if
Response.Write("It will cost you $" & price)


Set MyConn = nothing
Set RS  = nothing

%>
</body>

</html>