ASP-NSBA-MARK

Download Report

Transcript ASP-NSBA-MARK

National School Board Association
15th Annual Meeting
Technology & Learning Conference
November 8-10, 2001
Atlanta, GA
Catch the Vision...
Accessing Your Organization's Databases
Via the Web!
Mark Drone
Technology Services Director, Regional Office of Education
Bond, Fayette, and Effingham Counties, Illinois
Abe Loveless
Network Specialist
Area V Learning Technology Hub, Illinois
Paula Smith
Librarian
Paris Independent School District, Paris, TX
Getting Started with…
ASP Applications
Active Server Pages
With
Personal Web Server
And Internet Information Server!
INTERACTIVE WEB PAGES
Connecting the User to District Databases
Paula Smith
Librarian, Paris ISD
(Bennie Tschoerner)
Technology Director, Paris ISD
Paris Independent School District, Paris, TX
ASP and SQL:
Designing Large Scale Applications for
Professional Development Activities
Abe Loveless
Network Specialist,
Area V Learning Technology Center
Edwardsville, IL
Thinking Simple:
Getting Started in the ASP-Database
Application Design Game
Mark Drone
Technology Services Director,
Regional Office of Education
Bond, Fayette, Effingham Counties
Vandalia, IL
What are Active Server Pages?
Active Server Pages (ASP) are…





Basic web pages with added functionality
A Server-side technology (requiring a
Compatible Web Server)
Free (except for the Hardware and OS)
Easy to learn ~
More dynamic than plain HTML
What can I do with ASP?
Create Interactive Web Sites
Communicate with Databases on the
Web Server
Provide Search Capabilities to your
Web Site.
Set up Login/Password Access
Develop On-Line Applications
What do I need to make ASP?
An ASP Compatible
Web Server
A Text Editor or your
favorite HTML editor
Lots of
downloadable ASP
Applications
Internet Information Server
4.0 with SP3 and Option
Pack 4 running on Windows
NT Server 
Microsoft Personal Web
Server! 
Internet Information Server
5.0 running on Windows
2000 Professional or 2000
Server 
Where do I get a Compatible
Web Server?
On the Windows NT Option Pack 4
(free download if you have the time)
The Microsoft Frontpage98 CD-ROM

The Windows 98 CD-ROM 
Various sites you can find with a Search
Engine. Look for version 4.0
The installer package is about 4.2 MB.
Runs on Win95/98/ME
It’s free!

What About Windows 2000?
Windows 2000 Professional ships with
the Internet Information Server
(version 5) and can be installed using
the Add/Remove Control Panel
This presentation will deal with the
Personal Web Server rather than IIS
Both server versions are very similar
and most applications that work on
PWS also will work on IIS
Installing the Server checklist

 Windows 95/98/ME

 Network Interface
Card (NIC)

 Network
Connectivity

 Static IP Number
PWS Installation:
F
F
F
F
F
PWS Installation…
PWS Installation…
PWS Installation…
Maybe I should
get a cup of
coffee while this
is going on…
PWS Installation…
PWS Installation…
Look in the System Tray
for the PWS Icon
PWS Installation
(the 2nd time around or as a custom install)…
PWS Installation…
Setting Up Your Web Site…
Getting Started…
Configuring the Server…
Your Website
URL
Start/Stop
the Server
What’s going on
Themoment
Server
at this
Space
in time.
The Publishing Wizard…
More Publishing Wizard…
Home Page Wizard…
Product Tour…
Advanced Configuration…
Setting your “Root” directory…
A root directory is the location on your computer from which
the web server begins its filesystem hierarchy. The outside
world can’t see ‘further back’ in your computer’s structure
than this directory!
Creating “Virtual” Directories…
A virtual directory is a web server pseudonym that tells it to
look at a real directory on your computer. I can mask the
true structure of your computer file system.
The web server “maps” the pseudonym to the directory so
that calling http://yourserver/catalog/ will look for the
contents of c:\datastores.
Now…on to the Active Server Pages
Portion of the Program…
PWS
k
ASP
What are Active Server Pages?
Active Server Pages (ASP) are text files
with the extension .asp. They contain
any combination of the following:
Text
HTML tags
Server-side scripts
Active Server Pages…
Must be processed by the web server

Server interprets code and applies it to the
web pages it serves.
Files must end in “asp”

Default.asp, index.asp, homepage.asp
Server can serve plain vanilla web
pages also.
May include “delimiters”
How are HTML and ASP alike?
Both are written in plain text
Both can interpret HTML tags
A quick way to create an ASP file is to
rename your HTML files by replacing the
existing .htm or .html file name
extension with an .asp extension
Will I see anything different if
I change the ending
to *.asp?
Of course…you
have
to have the PWS or
IIS running and
in
HTML
render
serving
the will
pages!
Everything written
properly as an ASP page.
Take a regular web page, change the
ending to “.asp” and it will work fine.
Identical Files
http://localhost/charleston/testdoc.html
http://localhost/charleston/testdoc.asp
How are HTML and ASP pages
different?
ASP pages allow “server side scripts” to
be embedded in web pages
ASP has numerous built-in functions
that can be “imported” into web pages
ASP can detect information from User
input and make logical decisions based
on the information
ASP can let you build web applications
Example: Producing a Date
Stamp in HTML…
<HTML>
<BODY>
<h3>
This page was last refreshed on Nov 4, 2001
</h3>
</BODY>
Hard-coded
</HTML>
Click to View HTML Doc…
Example: Producing a Date
Stamp in ASP…
<HTML>
<BODY>
<h3>
This page was last refreshed on <%= Now() %>
</h3>
</BODY>
</HTML>
ASP Function
Click to View ASP Doc…
File Extensions are
important…
Normal web page files end in either…


*.html (like homepage.html)
*.htm (like default.htm)
ASP web page files end in

*.asp (like default.asp or index.asp)
*.htm
*.asp
The Key to ASP…
<% expression %>
The <% and %>
symbols tell the ASP
interpreter to
process the
information between
them and return any
information that the
system produces to
the browser window.
Mixing HTML and ASP…
<%
Comment
Delimiter
'Define two variables with string values.
strFirstName = "Jeff"
Establish Variable Value
strLastName = "Smith"
%>
HTML
Establish Variable Value
Delimiter
<P>This Web page is customized for “
Insert
<%= strFirstName %> &nbsp;
Insert
<%= strLastName %> ."
HTML
</P>
See Example
Conditionals…
“Get the Hour Portion of
the Date Function and
Assign That Number into
the dtmHour variable”
<%
Dimensioning the Variable
Dim dtmHour
Getting the Hour portion of the time
dtmHour = Hour(Now())
Start
If dtmHour < 12 Then
Then what?
Do this!
strGreeting = "Good Morning!"
Else
Or Else…
Variable
assignments
are
Do this!
strGreeting
= "Hello!"
read from right to left…
End If
Quit Thinking
“Take the value of the right
%>
side and assign it to the
Now Show the Result
<%= strGreeting %>variable
on the left side of
the equal sign”
For-Next Loops…
<%@ LANGUAGE=VBScript %>
<HTML>
<BODY>
<CENTER>
<% For N = 3 To 7 %>
<FONT SIZE = <% = N %> >
Welcome to the Conference!<BR>
</FONT>
<% Next %>
</CENTER>
</BODY>
</HTML>
Show me!
Examples of Basic ASP
pages…
This example consists of two files:
Form Values Sent to Response
FORM
RESPONSE
See it in action
The Form Code
<html>
The “ACTION=”
<HEAD>
NAME= and VALUE=
attribute points to the
<TITLE>Form</TITLE>
statements are very
</head>
response.asp page
<body >
important!
They are used to
<H2>Sample Form</A></H2>
build
the response page
<P>Please provide the following information, then click Submit:</P>
<FORM METHOD="POST" ACTION="response.asp">
First Name: <INPUT NAME="FirstName" SIZE="48">
<br><br>
Last Name: <INPUT NAME="LastName" SIZE="48">
<br><br>
Title: <INPUT NAME="Title" TYPE=RADIO VALUE="mr">Mr.
<INPUT NAME="Title" TYPE=RADIO VALUE="ms">Ms.
<P><INPUT TYPE=SUBMIT><INPUT TYPE=RESET></P>
</FORM>
</FONT>
</BODY>
</HTML>
The Response Page
(part 1)
Assign the Form
responses to
<% ‘Read values from the form and assign them to variables
variables
strTitle = Request.Form("Title")
<% @ LANGUAGE=VBScript %>
strFirstName = Request.Form("FirstName")
strLastName = Request.Form("LastName")
%>
<!-- Begin rendering HTML response -->
<html>
<HEAD>
<TITLE>Response.asp File</TITLE>
</head>
<body bgcolor="#FFFFFF" text="#000000">
The Response Page
(part 2)
<H2><CENTER>Wow! Someone submitted something!
</CENTER></H2>
<P ALIGN=CENTER> <font color="maroon" size="4">
<b>Thank you,
<%If strTitle = "mr" Then %>
Mr. <%= strLastName %>
<% ElseIf strTitle = "ms" Then %>
Ms. <%= strLastName %>
for clicking the submit button!<BR>
<% End If %>
</b></font></P>
Use logical
controls and
variables to
personalize the
response page
The Response Page
(part 3)
…
<h3 align=center>Let's see if we have this correct.
Your name is <%= strFirstName %> &nbsp; <%= strLastName %> ,
right?</h3>
</FONT>
</BODY>
</HTML>
Adding the
finishing touches
Using “Include” files…
A quick and easy way to build pages with similar
appearance.
<!--#include file=“\path\includelogin.asp"-->
<!--#include virtual=“/asp/navmenu.asp"-->
Insert headers, footers, navigation bars, etc. into
pages “on-the-fly”.
Change all pages by making changes to one file
only
Using “Include” files
(part 2)…
For example: create a file with the
following: <h1>
<img src = “mylogo.gif” align=“middle”>
My Own Website
<hr> </h1>
Name it “heading.asp”
Insert it in every web page on your site
with:
<!--#include file=“heading.asp”
Using “Include” files
(part 3)…
Another example:
<hr>
<address>
Copyright &copy; 2001 Mark Drone, all
rights reserved. Duplication prohibited
without written consent of author.
</address><hr>
Name it “copyright.asp”
Insert it in every web page on your site
with:
<!--#include file=“copyright.asp”
Capturing and Retrieving Data
To collect and save the information from
forms, there needs to be some kind of data
collecting device operating in the background.
Databases work nicely.
Possible Database Engines include:



Access
Excel
SQL Server
Making the Database…
Open Microsoft Access and create a
new database (call it “addressbook.mdb”)
Create a table in the database (call it
“Friends”)
Create the data cells that you would like
to keep for your friends (like telephone
numbers, email addresses, etc.)
See the database…
Making the Database
Connection in a Script…
This section tells the web server that
the script wants to open up a
connection to a database. It tells it
where it is and what tools to use to
<%@ LANGUAGE=VBScript %>
open it. (this code is reusable!)
<%
strDBVirtualPath = "/virtual/path/to/database.mdb"
strDBLocation = Server.Mappath(strDBVirtualPath)
strSource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBLocation
Set objConnection = Server.CreateObject("ADODB.Connection")
This section talks to the
objConnection.Open strSource
%>
<%
database
table and extracts information from
it, storing it in the
“rsCustomersList” variable.
SQLQuery = "SELECT * FROM Friends"
Set rsCustomersList = objConnection.Execute(SQLQuery)
%>
Using the database.asp script
It reads from the database only.
It contains a mixture of HTML and VB
scripting
It shows an example of how to code in
email links
See the database.asp
page in action
Creating the Variables
<%
'1. Set the Virtual Path to the database and store it in a variable
strDBVirtualPath = "/charleston/simple/addressbook.mdb"
'2. Create the Server Mapping Object and store it in a variable
strDBLocation = Server.Mappath(strDBVirtualPath)
'3. Establish the Data Source Command and store it in a variable (using
the & connector)
strSource = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
strDBLocation
'4. Create the Connection Object
Set objConnection = Server.CreateObject("ADODB.Connection")
Creating
theI Variables
How will
ever
remember all
Do what I do…
this code!?
'6. Write the SQL statement to pull information from the database
'5. Open the connection to the database
objConnection.Open strSource
• Save it in a text file
SQLQuery = "SELECT * FROM Friends"
• Copy and Paste from the
text
file whenever
'7. Create an object that
executes
the SQL query you need
Set rsFriendsList = database
objConnection.Execute(SQLQuery)
connection code.
%>
• Set the code snippets up as
“include” files.
Building the HTML Table from
the Database (part 1)
<TABLE COLSPAN=8 CELLPADDING=10 CELLSPACING=0 BORDER=0>
<!-- BEGIN column header row -->
<TR>
<TD ALIGN=CENTER BGCOLOR="#008080">
<FONT COLOR="#FFFFFF" SIZE=4><B>Contact Name</B></FONT>
</TD>
<TD ALIGN=CENTER BGCOLOR="#008080">
<FONT COLOR="#FFFFFF" SIZE=4><B>E-mail address</B></FONT>
</TD>
<TD ALIGN=CENTER BGCOLOR="#008080">
<FONT COLOR="#FFFFFF" SIZE=4><B>City</B></FONT>
</TD>
<TD ALIGN=CENTER BGCOLOR="#008080">
<FONT COLOR="#FFFFFF" SIZE=4><B>State</B></FONT>
</TD>
<TD ALIGN=CENTER BGCOLOR="#008080">
<FONT COLOR="#FFFFFF" SIZE=4><B>Telephone</B></FONT>
</TD>
</TR>






Building the HTML Table from
the Database (part 2)
<% Do Until rsFriendsList.EOF%>
Remember the
rsFriendsList
variable?
<TR>
<TD BGCOLOR="f7efde" ALIGN=left>
<%= rsFriendsList("FirstName")%>&nbsp;<%=
rsFriendsList("LastName") %>
</TD>
<TD BGCOLOR="f7efde" ALIGN=left>
<a href="mailto:<%= rsFriendsList("Email")%>">
<%= rsFriendsList("Email")%> </a>
</TD>
<TD BGCOLOR="f7efde" ALIGN=left>
<%= rsFriendsList("City")%>
</TD>
…..(continued)…..
These variables
are referencing
fields in the
database
Building the HTML Table from
the Database (part 3)
…..(continued)…..
<TD BGCOLOR="f7efde" ALIGN=left>
<%= rsFriendsList("State")%>
</TD>
<TD BGCOLOR="f7efde" ALIGN=left>
<%= rsFriendsList("Telephone")%>
</TD>
</TR>
<!-- Loop Through the Records -->
<%
rsFriendsList.MoveNext
Loop
%>
eMail Addresses/URLs
 Paris ISD Internet Site
http://www.parisisd.net
 Project PERC Web Site
http://www.ProjectPerc.net
 eMail
[email protected]
eMail Addresses/URLs
 Area 5 Learning Technology
Center
http://www.lth5.k12.il.us/
 LITES Project Home
http://www.lites.lth5.k12.il.us/
 eMail
[email protected]
eMail Addresses/URLs
Regional Office of Education
http://www.fayette.k12.il.us/
Resources
http://www.fayette.k12.il.us/atlanta/
eMail
[email protected]
Questions and Answers…
…Samples and Examples