Active Server Pages: Web Scripting Made Easy A Hands-On Workshop in the New Brunswick Computing Services Instructional Lab...
Workshop Overview <ul><li>Fast paced five-part workshop designed to prepare you to create a truly dynamic site using Activ...
Workshop Goals <ul><li>By the End of the Workshop You Will: </li></ul><ul><ul><li>Understand the concepts and components o...
Active Server Pages Workshop:  About Your Instructor <ul><li>6 Years Experience With Web Technologies in Higher Ed and Ind...
About You and Your Classmates <ul><li>Who Are Your Classmates? </li></ul><ul><li>What Do Your Classmates Do With Computers...
“ Active Server Pages” Administrative Information <ul><li>Course Slides in Hard Copy and on the Web </li></ul><ul><li>Prer...
Demos and Hands-on Exercises:  About The Systems <ul><li>Will Use an NT Server (clio.rutgers.edu) and Workstations in the ...
A Note on Remote NT Systems Management <ul><li>Free Option: Virtual Network Computing </li></ul><ul><ul><li>Available from...
Active Server Pages: Part I Topics:  “Review of Client and Server-Side Scripting”; “Getting Up and Running”;  “Introducing...
Part I Goals <ul><li>Discuss client side/server side scripting  </li></ul><ul><li>Introduce Active Server Pages (ASP) </li...
“ Active Server Pages”  5 Parts at a Glance <ul><li>Part 1: Introduction </li></ul><ul><li>Part 2: ASP Scripting in VBScri...
Client-Side and Server-Side Scripting: Your Web Development Options? <ul><li>Code Must  Reside  on a Server </li></ul><ul>...
Benefits of Server-Side Scripting:  Some Basic Things to Consider <ul><li>Why Use Server-Side Scripts? </li></ul><ul><li>P...
Benefits of Server-Side Scripting:  Some Basic Things to Consider <ul><li>Why Use Active Server Pages Instead of CGI? Ease...
ASP Definition <ul><li>“ Active Server Pages is an open, compile-free application environment in which you can combine HTM...
ASP and The CGI Model <ul><li>ASP = Active Server Pages </li></ul><ul><li>Another Form of Server-Side Scripting  </li></ul...
Benefits of Using Active Server Pages <ul><li>Customize Content on Per-Browser Basis </li></ul><ul><li>Use Cookies to Cust...
What You Need to Make ASP Work <ul><ul><li>ASP Supported By Default in IIS 4.0 </li></ul></ul><ul><ul><li>Use NT Server Wi...
Steps to Enabling ASP Support <ul><li>IIS 4 and PWS 4 Support ASP By Default </li></ul><ul><ul><li>Both Available for Free...
Using ASP With IIS 4: A Review of MMC and ISM <ul><li>URLs and IIS Directory Structure </li></ul><ul><li>Internet Guest Ac...
The Internet Guest Account <ul><li>Installation Will Create the Internet Guest Account, Which is there to Allow Anonymous ...
Microsoft Management Console (MMC) and the NT Service Manager <ul><li>MMC Is an Interface to the  NT Service: “Web Publish...
Using ASP With PWS 4: The Administrative Interface <ul><li>Review of Virtual Directories  </li></ul><ul><li>Permissions: R...
Virtual Servers vs.  Virtual Directories <ul><li>Virtual Servers   Are Separate Hostnames On the Same Physical Machine Bou...
Languages Used for ASP? <ul><li>What Are ASP Pages Written In? </li></ul><ul><ul><li>VBScript </li></ul></ul><ul><ul><li>J...
Most Common Language: VBScript Defined <ul><li>“ Microsoft® Visual Basic® Scripting Edition, a subset of the Microsoft® Vi...
Ways to Write ASP Code: Your Choice of Editors <ul><li>Any Test Editor: Notepad, vi (MKS Toolkit) </li></ul><ul><li>FrontP...
Using FrontPage 98 <ul><li>This Course Will Use FP98 as Editor </li></ul><ul><li>To Prevent FP 98 From Changing Code: </li...
Structure of an ASP Page <ul><li>ASP Script Code Mixed in Page With Regular HTML Code </li></ul><ul><li>2 Ways to Denote A...
<HTML> <HEAD> <TITLE>Polite Web Server</TITLE> </HEAD> <BODY BGCOLOR=&quot;wheat&quot;> <P> <FONT COLOR=&quot;Teal&quot; S...
In-Class Demo of Simple Script <ul><li>The Simple “Punctual Web Server” Program (Example From Wrox.com) </li></ul><ul><li>...
Active Server Pages: Part II Topics:  “HTML Forms” and “VBScript Basics: Variables, Variants, Operators, String Manipulati...
Goals For Part II <ul><li>Review Use of Forms </li></ul><ul><li>Introduce ASP Basics: HTML Forms and Variables With VBScri...
Review of HTML Forms <ul><li>Pieces of the HTML Form (YourColor.html) </li></ul><ul><ul><li><FORM ACTION=“colors.asp&quot;...
Using Forms in FP 2000 <ul><li>By Default FrontPage 2000 Wants To Send Output To a Text File on the Server </li></ul><ul><...
Sample Form Code From FP 2000 <ul><li><form method= &quot;POST&quot;  action= &quot;--WEBBOT-SELF--&quot; > </li></ul><ul>...
Using ASP Pages to Process User Input From HTML Forms <ul><li>Sent Your Form Data to colors.asp, So Now We Need a file cal...
What are Variables? <ul><li>“ A  variable  is a section of memory that is allocated a name by the programmer. These sectio...
Using Variables in an ASP Page <ul><li>Here is the Code for colors.asp: </li></ul><ul><li><HTML> </li></ul><ul><li><H1> So...
Another Example of Form Input:  The Need to Normalize Data <ul><li>Use of Drop Down Menu to Give User Choices For Data Ent...
Creating the ASP Page  To Handle Drop-Down Menu Items <ul><li>choosing.asp contains the following code: </li></ul><ul><li>...
Hands-On Exercise 1: Download and Install Sample Code <ul><li>Download and Install Examples From Wrox.com Site </li></ul><...
Hands-On Exercise 2:  Forms and ASP  <ul><li>View Samples From Chapter 3  </li></ul><ul><ul><li>Forms: </li></ul></ul><ul>...
Naming Variables in VBScript <ul><li>Limit is 255 characters  </li></ul><ul><li>All variable names must begin with an alph...
VBScript Variables and Variants <ul><li>Most programming languages allow you to declare data types for your variables </li...
Use of Operators in VBScript <ul><li>Assignment  </li></ul><ul><li>Comparison </li></ul><ul><li>Logical </li></ul><ul><li>...
String Manipulation in VBScript <ul><li>Len </li></ul><ul><li>Left </li></ul><ul><li>Right </li></ul><ul><li>Mid </li></ul...
Arrays in VBScript <ul><li>The Purpose of Arrays </li></ul><ul><li>Array Declaration </li></ul><ul><li>Dim StudentsInClass...
Hands-On Exercise 3:  Strings and Arrays in VBScript   <ul><li>Examples From Chapter 4  </li></ul><ul><ul><ul><li>Using a ...
What We Accomplished This Morning in Part I <ul><li>Introduced the Course </li></ul><ul><li>Discussed client side/server s...
What We Accomplished This Morning in Part II <ul><li>Reviewed Use of Forms </li></ul><ul><li>Introduced ASP Basics: HTML F...
Reference Materials in Parts I & II <ul><li>Beginning Active Server Pages 2.0 </li></ul><ul><ul><li>Chapter 1 “Getting Sta...
<ul><li>ASP Docs on Your IIS Server: </li></ul><ul><li>http://your_server/iishelp/iis/misc/default.asp </li></ul><ul><ul><...
Lunch Break Take 45 Minutes to Eat!
Active Server Pages: Part III Topics:  “Flow Control in VBScript”  “ASP Objects” and “The Visual InterDev 6.0 IDE”
<ul><li>Discuss Flow Control in VBScript </li></ul><ul><li>Work on Flow Control Examples With VBScript and ASP </li></ul><...
What We Covered Right Before Lunch <ul><li>Reviewed Use of Forms </li></ul><ul><li>Introduced ASP Basics: HTML Forms and V...
What is Flow Control? Action vs. Control Statements <ul><li>“ Action statements:  Statements that perform an activity, suc...
Types of Control Structures <ul><li>Branching </li></ul><ul><ul><li>If … Then </li></ul></ul><ul><ul><li>Select … Case </l...
If … Then … Else <ul><li>Used to select one of two sets of lines to execute.  </li></ul><ul><li>Also used for complicated ...
Flow Control Walkthrough 1: TioIfThenOneForm.asp <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>Spring R...
Flow Control Walkthrough 1 Cont.: TioIfThenOneForm.asp <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>Sp...
Select … Case <ul><li>Used anytime you need to make a choice among several answers (more than just True and False) then us...
Flow Control Walkthrough 2: TioSelectOneForm.asp   <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>Spring...
Flow Control Walkthrough 2 Cont.: TioSelectOneResponse.asp   <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TI...
Types of Looping Statements: For…Next; For … Each … Next; Do …While <ul><li>“ ForNext  is used to repeat line(s) when, at ...
Flow Control Walkthrough 3: TioForNextOneForm.asp   <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>TIO F...
Flow Control Walkthrough 3 Cont.:  TioSelectOneResponse.asp   <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><T...
Hands on Flow Controls <ul><li>Modify the TioIfThenOne set of examples to Make the Event Occur in the Winter  </li></ul><u...
Write One Time, Run Many Times: Code Reuse in ASP <ul><li>Within A Single ASP Page, May Need to Insert Some Code in a Numb...
What Are ASP Procedures? <ul><li>“ Subprocedures  carry out an action: for example, a  Sub  would be used to carry out the...
Creating a Sub <ul><li>3 Parts of a Procedure </li></ul><ul><ul><li>The procedure’s  nam e </li></ul></ul><ul><ul><li>The ...
ASP Subprocedure Example: SubExample.asp
ASP Function Example: TioFunctionForm.asp <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>TIO Function Fo...
ASP Function Example: TioFunctionResponse.asp
Use of Objects in ASP <ul><li>Objects </li></ul><ul><li>Methods </li></ul><ul><li>Properties </li></ul><ul><li>Events </li...
About Visual InterDev 6.0 <ul><li>Microsoft’s Integrated Development Environment for Web Development </li></ul><ul><li>Mic...
Visual InterDev 6.0 Walkthrough <ul><li>Setting Up and Configuring the Client and Server Environments </li></ul><ul><li>Th...
Getting Visual InterDev 6.0 <ul><li>Trial Version Available for Download (Times Out) </li></ul><ul><li>InterDev 6.0 is Par...
Class Break Take 15 Minutes to Stretch!
Active Server Pages: Part IV Topics: “The ASP Object Model in Depth” and “ASP Components”
<ul><li>Review Object-Oriented Programming Concepts and Explain the ASP Object Model </li></ul><ul><li>Discuss ASP Request...
Object-Oriented Programming <ul><li>Some Key Terms </li></ul><ul><ul><li>Instance </li></ul></ul><ul><ul><li>Properties </...
The ASP Object Model: Three Levels <ul><li>Page Level Objects </li></ul><ul><ul><li>Request </li></ul></ul><ul><ul><li>Res...
Page-Level Objects: The Request Object <ul><li>Collections </li></ul><ul><ul><li>QueryString </li></ul></ul><ul><ul><li>Fo...
Page-Level Objects: The Response Object <ul><li>Write and Redirect Methods </li></ul><ul><li>The Response.write Shortcut <...
Application-Level Objects: The Application Object <ul><li>Challenge of Maintaining State </li></ul><ul><li>Virtual Directo...
Application-Level Objects: global.asa in Detail <ul><li>Event Handling Subroutines: </li></ul><ul><ul><li>Application_OnSt...
Application-Level Objects: The Session Object <ul><li>Defining a Session </li></ul><ul><li>Why would this be “the most pow...
Application-Level Objects: The Session Object (Cont) <ul><li>Session Object  Properties  include: </li></ul><ul><ul><li>Se...
Using Cookies in ASP <ul><li>Difference Between Session-Level Variables and Cookies?  </li></ul><ul><li>Period of Persiste...
Hands-On Exercise: Working With Page and Application-Level Objects <ul><li>Exercise Files For Work With ASP Objects Taken ...
ASP Components and  Sever Objects <ul><li>ASP Components are Server-Level Objects That are Instantiated in Your Code in Or...
Default Components Using Visual InterDev 6.0 <ul><li>Drag and Drop Objects </li></ul><ul><li>Location: In Toolbox, Under S...
Hands-On Exercises: Trying Out ASP Components <ul><li>Exercise Files For This Part’s Work With ASP Components Taken From C...
Active Server Pages: Part V Topics:  “ASP Scripting Objects”  “Debugging” and “ASP Data Store Connectivity Using ADO Compo...
Goals For Part V <ul><li>Finish Coverage of Built-in ASP Component Examples </li></ul><ul><li>Briefly Cover the ASP Script...
Trying Out ASP Components <ul><li>Exercise Files From Part IV Work With ASP Components Taken From Chapter 12 in  Beginning...
ASP Scripting Objects <ul><li>Dictionary Object Allows You To Store Keyed Values  </li></ul><ul><li>FileSystemObject and F...
Basic Debugging Tips:  Using A Text Editor and a Browser <ul><li>Use Option Explicit to Force Variable Declaration </li></...
Debugging Under Win 32: MS Script Debugger & VI 6.0 <ul><li>Dearth of Robust Debugging Tools. </li></ul><ul><li>Yet, Scrip...
What and How You Connect: Data Stores and Connections <ul><li>Database as subset of Data Store. </li></ul><ul><li>Connecti...
The ODBC Data Source Administrator
Setting Up ODBC Access:  4 Steps to Creating a DSN <ul><li>Step 1: Select ODBC From the Control Panel </li></ul><ul><li>St...
Adding a Data Source Name (DSN) STEP 1 STEP 2 STEP 3 STEP 4
Using the DSN in ASP Code <ul><li>DSN Resides on the Server Where the ASP Code Runs (Implications For Develop Locally/Serv...
ActiveX Data Object Component <ul><li>ADO is the “friendly face of OLE-DB” </li></ul><ul><li>Superset of DAO (Data Access ...
What We Accomplished This Afternoon in Part III <ul><li>Reviewed Pre-Lunch Discussion  </li></ul><ul><li>Discussed Flow Co...
<ul><li>Reviewed Object-Oriented Programming Concepts and Explain the ASP Object Model </li></ul><ul><li>Discussed ASP Req...
<ul><li>Finished Coverage of Built-in ASP Component Examples </li></ul><ul><li>Briefly Covered the ASP Scripting Objects <...
Where Do We Go From Here? <ul><li>Read  Beginning Active Server Pages 2.0 </li></ul><ul><li>Consider More SQL Readings </l...
<ul><li>Beginning Active Server Pages 2.0 </li></ul><ul><ul><li>Chapter 6 “Objects, Properties, Methods and Events” </li><...
<ul><li>Beginning Active Server Pages 2.0 </li></ul><ul><ul><li>Read Chapter 9 “Applications, Sessions and Cookies” </li><...
Web Development Resources Indexes <ul><li>Yahoo </li></ul><ul><ul><li>http://dir.yahoo.com/Computers_and_Internet/Internet...
What We Accomplished Today <ul><li>Reviewed MS FrontPage 2000’s Basic Features and Began to Utilize it as a development en...
For Further Information <ul><li>See the Seminar Site at: </li></ul><ul><li>http://www.clioweb.net/mdobe/teaching/1999/NJIN...
Upcoming SlideShare
Loading in …5
×

Rutgers - Active Server Pages

6,134 views

Published on

Published in: Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,134
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
12
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Rutgers - Active Server Pages

    1. 1. Active Server Pages: Web Scripting Made Easy A Hands-On Workshop in the New Brunswick Computing Services Instructional Lab By Michael Dobe Sponsored by The New Jersey Intercampus Network Internet Technology Project http://www.njin.net
    2. 2. Workshop Overview <ul><li>Fast paced five-part workshop designed to prepare you to create a truly dynamic site using Active Server Pages, VBScript, and Microsoft's IIS 4.0 Server on the Internet or on a college/university intranet. </li></ul>
    3. 3. Workshop Goals <ul><li>By the End of the Workshop You Will: </li></ul><ul><ul><li>Understand the concepts and components of Active Server Pages </li></ul></ul><ul><ul><li>Know the steps to set up and configure development and production ASP Server environments </li></ul></ul><ul><ul><li>Learn the basics of ASP Scripting With VBScript </li></ul></ul><ul><ul><li>Manage states and events with application and session objects </li></ul></ul><ul><ul><li>Understand and use the bundled Active Server components </li></ul></ul><ul><ul><li>Connect to a MS Access database and display information </li></ul></ul><ul><ul><li>Know the steps to create your own ASP components </li></ul></ul>
    4. 4. Active Server Pages Workshop: About Your Instructor <ul><li>6 Years Experience With Web Technologies in Higher Ed and Industry </li></ul><ul><li>Designed and Implemented </li></ul><ul><ul><li>Clio Web Project For Internet Web Hosting at Rutgers </li></ul></ul><ul><ul><li>Corporate Intranets for BMG Direct Marketing and Warburg Dillon Read, LLC </li></ul></ul><ul><li>Currently Working As Web Architect for Modem Media.Poppe Tyson. </li></ul><ul><li>See the Instructor’s Home Page at http://clioweb.net/mdobe </li></ul>FOR MORE INFO...
    5. 5. About You and Your Classmates <ul><li>Who Are Your Classmates? </li></ul><ul><li>What Do Your Classmates Do With Computers? </li></ul><ul><li>What Motivated You to Take This Course? </li></ul><ul><li>What Do You Hope to Get Out of This Workshop? </li></ul>
    6. 6. “ Active Server Pages” Administrative Information <ul><li>Course Slides in Hard Copy and on the Web </li></ul><ul><li>Prerequisites: Experience With HTML and Web Server Technologies; some scripting experience desirable </li></ul><ul><li>Reference Book, Beginning Active Server Pages 2.0 , is available from “brick and mortar” and online retailers </li></ul><ul><li>Workshop runs from 9:30-4:00 PM </li></ul><ul><li>See the NJIN Web Site at http://www.njin.net </li></ul>FOR MORE INFO ...
    7. 7. Demos and Hands-on Exercises: About The Systems <ul><li>Will Use an NT Server (clio.rutgers.edu) and Workstations in the Classroom For this Workshop </li></ul><ul><li>Web Server Demos Using VNC (Virtual Network Computing) </li></ul><ul><li>Will Make Use of Web Browsers, MS-FrontPage 2000, MS Office 2000 and Visual InterDev 6.0 </li></ul><ul><li>Workstation Configurations Will Allow You To Create and Modify FrontPage 2000 Webs on the Web Server and to Author ASP Pages </li></ul>http://www. njin .net
    8. 8. A Note on Remote NT Systems Management <ul><li>Free Option: Virtual Network Computing </li></ul><ul><ul><li>Available from http://www.uk.research.att.com/vnc/ </li></ul></ul><ul><li>Commercial Options: </li></ul><ul><ul><li>pcANYWHERE </li></ul></ul><ul><ul><li>Timbuktu </li></ul></ul><ul><li>Using VNC, You Can Manage NT Server From a PC Workstation </li></ul>
    9. 9. Active Server Pages: Part I Topics: “Review of Client and Server-Side Scripting”; “Getting Up and Running”; “Introducing ASP and VBScript ”
    10. 10. Part I Goals <ul><li>Discuss client side/server side scripting </li></ul><ul><li>Introduce Active Server Pages (ASP) </li></ul><ul><li>Explain what platforms these scripts run on and which browsers can see the results </li></ul><ul><li>Discuss configuration of development and production ASP environments </li></ul><ul><li>Discuss the structure of an ASP page </li></ul><ul><li>Introduce VBScript, the default scripting language for ASP </li></ul>
    11. 11. “ Active Server Pages” 5 Parts at a Glance <ul><li>Part 1: Introduction </li></ul><ul><li>Part 2: ASP Scripting in VBScript, Pt. I </li></ul><ul><li>Part 3: ASP Scripting in VBScript, Pt. II </li></ul><ul><li>Part 4: ASP Components </li></ul><ul><li>Part 5: ADO Components </li></ul>
    12. 12. Client-Side and Server-Side Scripting: Your Web Development Options? <ul><li>Code Must Reside on a Server </li></ul><ul><li>Code Can Be Executed </li></ul><ul><ul><li>On a Server (Server-Side Scripts) </li></ul></ul><ul><ul><li>In a Client Browser (Client-Side Scripts) </li></ul></ul><ul><li>Client-Side Scripting Limitations? </li></ul><ul><li>Reality: May Run a Mix of Code, Some Intended For Client and Other For Server-Side Execution </li></ul>
    13. 13. Benefits of Server-Side Scripting: Some Basic Things to Consider <ul><li>Why Use Server-Side Scripts? </li></ul><ul><li>Protection of Your Source Code: </li></ul><ul><li>People Can’t See the Source Code, Only the HTML the Server Returns to the Browser </li></ul><ul><li>Independence From Browser Specificity: Server-Side Scripts Work With Any Browser! </li></ul>
    14. 14. Benefits of Server-Side Scripting: Some Basic Things to Consider <ul><li>Why Use Active Server Pages Instead of CGI? Ease of Use? Speed? </li></ul><ul><li>OS Platform </li></ul><ul><li>ASP Default Server-Side Scripting on IIS, But CGI (and even Perl) work on NT ... </li></ul>
    15. 15. ASP Definition <ul><li>“ Active Server Pages is an open, compile-free application environment in which you can combine HTML, scripts, and reusable ActiveX server components to create dynamic and powerful Web-based business solutions. Active Server Pages enables server side scripting for IIS with native support for both VBScript and Jscript.” </li></ul><ul><li>- Nancy Winnick Cluts (MSDN Web Workshop) </li></ul>
    16. 16. ASP and The CGI Model <ul><li>ASP = Active Server Pages </li></ul><ul><li>Another Form of Server-Side Scripting </li></ul><ul><li>Like CGI, Can Be Used With Any Browser </li></ul><ul><li>Also Like CGI, Users See the HTML Code and Not the Script Itself </li></ul><ul><li>Unlike CGI, It Is Tied to the Microsoft Platform ... Well, sort of ... </li></ul>
    17. 17. Benefits of Using Active Server Pages <ul><li>Customize Content on Per-Browser Basis </li></ul><ul><li>Use Cookies to Customize Individual’s Browsing Experience </li></ul><ul><li>Tight Integration With OS </li></ul><ul><ul><ul><li>Run as Service in NT </li></ul></ul></ul><ul><ul><ul><li>Tie-in To MS ACLs (Access Control Lists) </li></ul></ul></ul><ul><li>Support For ActiveX Server Components (Sever-Side Execution Eliminates Browser-Specificity) </li></ul>
    18. 18. What You Need to Make ASP Work <ul><ul><li>ASP Supported By Default in IIS 4.0 </li></ul></ul><ul><ul><li>Use NT Server With Internet Information Server 4.0 For Production Web Environment </li></ul></ul><ul><ul><li>For Development You Can Use Personal Web Server for Win 95/98 and Peer Web Services for NT Workstation 4.0 (Both Called PWS) </li></ul></ul><ul><ul><li>Need PWS Version 4 For ASP! </li></ul></ul><ul><ul><li>PWS Version Included With FP 98 Does Not Support ASP!!!!! </li></ul></ul>
    19. 19. Steps to Enabling ASP Support <ul><li>IIS 4 and PWS 4 Support ASP By Default </li></ul><ul><ul><li>Both Available for Free as Part of NT Server 4 Option Pack </li></ul></ul><ul><ul><li>IIS Documentation Installs With Option Pack: </li></ul></ul><ul><li>Chili!Soft Offers Extensions For Other Non-MS Operating Systems and Web Servers </li></ul><ul><ul><li>Available for Apache, Lotus, Netscape and O'Reilly, running on Windows NT, Sun Solaris and IBM AIX </li></ul></ul><ul><ul><li>http://www.chilisoft.com/ </li></ul></ul>
    20. 20. Using ASP With IIS 4: A Review of MMC and ISM <ul><li>URLs and IIS Directory Structure </li></ul><ul><li>Internet Guest Account </li></ul><ul><li>Web Publishing Service </li></ul><ul><li>Internet Service Manager: </li></ul><ul><ul><li>GUI Tools </li></ul></ul><ul><ul><li>HTML Interface </li></ul></ul><ul><li>Tools Demonstration </li></ul><ul><li>URLs and File Structure of IIS </li></ul>
    21. 21. The Internet Guest Account <ul><li>Installation Will Create the Internet Guest Account, Which is there to Allow Anonymous Access to Browse Your Site </li></ul><ul><li>The Internet Guest Account is called IUSER_computername (computername is your server’s NetBIOS name) </li></ul><ul><li>The Web Application Manager user account is IWAM_computername </li></ul>
    22. 22. Microsoft Management Console (MMC) and the NT Service Manager <ul><li>MMC Is an Interface to the NT Service: “Web Publishing Services” </li></ul><ul><li>Used to Manage the Hypertext Transfer Protocol Server (IIS) and Other TCP/IP Services </li></ul><ul><li>DEMONSTRATION OF ISM </li></ul><ul><ul><li>GUI Tool: MMC </li></ul></ul><ul><ul><li>HTML Version </li></ul></ul>
    23. 23. Using ASP With PWS 4: The Administrative Interface <ul><li>Review of Virtual Directories </li></ul><ul><li>Permissions: Read, Execute, Scripts </li></ul><ul><li>Virtual Directory Mapping Implementations on PWS 4 and IIS 4 </li></ul><ul><li>Creating Your Project Virtual Directory </li></ul><ul><li>Ready For Your First Server-Side Script in ASP? </li></ul>
    24. 24. Virtual Servers vs. Virtual Directories <ul><li>Virtual Servers Are Separate Hostnames On the Same Physical Machine Bound to Different NICs (or Bound to Same NIC) Virtual Servers Have Their Own Separate Configs. Virtual Servers Appear to the Outside World as Separate Machines. </li></ul><ul><li>Virtual Directories Are Directories Which Appear Below the Root Directory in a Web Browser. May Be Located on the Same Physical Machine or on Another Machine. Virtual Directories Appear to the Outside World as Part of the Same Server. </li></ul><ul><ul><li>Why Would You Use a Virtual Server or a Virtual Directory? </li></ul></ul><ul><ul><li>Perhaps you would use a Virtual Directory for Active Server Pages? </li></ul></ul>
    25. 25. Languages Used for ASP? <ul><li>What Are ASP Pages Written In? </li></ul><ul><ul><li>VBScript </li></ul></ul><ul><ul><li>JScript (JavaScript) </li></ul></ul><ul><ul><li>PerlScript (ActiveState Tool Corp.) </li></ul></ul><ul><li>ASP can integrate Java and ActiveX Technologies. Usually the Latter. </li></ul>
    26. 26. Most Common Language: VBScript Defined <ul><li>“ Microsoft® Visual Basic® Scripting Edition, a subset of the Microsoft® Visual Basic® programming language, is a fast, portable, lightweight interpreter for use in World Wide Web browsers and other applications that use Microsoft® ActiveX® Controls, Automation servers, and Java applets.” </li></ul><ul><li>- Microsoft Script Technologies Site </li></ul>
    27. 27. Ways to Write ASP Code: Your Choice of Editors <ul><li>Any Test Editor: Notepad, vi (MKS Toolkit) </li></ul><ul><li>FrontPage 98 or 2000 </li></ul><ul><ul><li>98 Sometimes Alters Code </li></ul></ul><ul><ul><li>Workaround is Available </li></ul></ul><ul><ul><li>2000 Support is More Robust </li></ul></ul><ul><li>Visual InterDev 6.0 </li></ul><ul><ul><li>Part of Visual Studio </li></ul></ul><ul><ul><li>Group Development Tool </li></ul></ul>
    28. 28. Using FrontPage 98 <ul><li>This Course Will Use FP98 as Editor </li></ul><ul><li>To Prevent FP 98 From Changing Code: </li></ul><ul><ul><li>Using the FrontPage Editor Menu, </li></ul></ul><ul><ul><li>Select Insert | FrontPageComponent | InsertHTML </li></ul></ul><ul><ul><li>option to place </li></ul></ul><ul><ul><li><!--webbot bot=&quot;HTMLMarkup&quot; startspan --> and <!--webbot bot=&quot;HTMLMarkup&quot; endspan --> </li></ul></ul><ul><ul><li>tags around your ASP code, so that is not modified by FrontPage. </li></ul></ul>
    29. 29. Structure of an ASP Page <ul><li>ASP Script Code Mixed in Page With Regular HTML Code </li></ul><ul><li>2 Ways to Denote ASP Scripts </li></ul><ul><ul><li><% Here is a Script %> </li></ul></ul><ul><ul><li><SCRIPT LANGUAGE=VBSCRIPT RUNAT=SERVER> </li></ul></ul><ul><li>We Will Use the Former Convention </li></ul>
    30. 30. <HTML> <HEAD> <TITLE>Polite Web Server</TITLE> </HEAD> <BODY BGCOLOR=&quot;wheat&quot;> <P> <FONT COLOR=&quot;Teal&quot; SIZE=&quot;3&quot;><B> The Polite Web Server, at <%= Time %> on <%= Date %> </B></FONT></P> <P><B> <% If Hour(Now) < 8 Then %> Don't you know what time it is? I was still in bed! <% Else Randomize intChoice = Int(Rnd * 4) Select Case intChoice Case 0 %> So, where do you want me to go today? <% Case 1 %> Well, look whose back visiting us again... <% Case 2 %> Hi there, and welcome to our site. <% Case 3 %> It's raining here, what's the weather at your end like? <% End Select End If %> </B></P> <HR> </BODY> </HTML>
    31. 31. In-Class Demo of Simple Script <ul><li>The Simple “Punctual Web Server” Program (Example From Wrox.com) </li></ul><ul><li>Write Program in FP 2000 </li></ul><ul><li>Run Code on a Workstation Using Personal Web Server </li></ul><ul><li>Test and Troubleshoot </li></ul>
    32. 32. Active Server Pages: Part II Topics: “HTML Forms” and “VBScript Basics: Variables, Variants, Operators, String Manipulation and Arrays”
    33. 33. Goals For Part II <ul><li>Review Use of Forms </li></ul><ul><li>Introduce ASP Basics: HTML Forms and Variables With VBScript </li></ul><ul><li>Download and Install Sample Code From Wrox.com </li></ul><ul><li>Work on Forms-based Examples </li></ul><ul><li>VBScript Variables in Depth </li></ul><ul><li>Strings and Arrays </li></ul><ul><li>Work on String Manipulation and Array Examples </li></ul>
    34. 34. Review of HTML Forms <ul><li>Pieces of the HTML Form (YourColor.html) </li></ul><ul><ul><li><FORM ACTION=“colors.asp&quot; METHOD=post> </li></ul></ul><ul><ul><li><P>Please Type Your Favorite Color Here:</P> </li></ul></ul><ul><ul><li><P><INPUT NAME=&quot;MyFavoriteColor&quot; ></P> </li></ul></ul><ul><ul><li><INPUT TYPE=&quot;submit&quot; VALUE=&quot;Submit This Form&quot;> </li></ul></ul><ul><ul><li><P></P> </li></ul></ul><ul><ul><li><P><INPUT TYPE=&quot;reset&quot; VALUE=&quot;Reset This Form&quot;></P> </li></ul></ul><ul><ul><li></FORM> </li></ul></ul>
    35. 35. Using Forms in FP 2000 <ul><li>By Default FrontPage 2000 Wants To Send Output To a Text File on the Server </li></ul><ul><li>Inserting Form Elements in the “Normal View” Inserts a FrontPage Bot, a.k.a. “FrontPage Component” </li></ul><ul><li>Best to Hand Code the HTML for the Forms in the “HTML View” </li></ul>
    36. 36. Sample Form Code From FP 2000 <ul><li><form method= &quot;POST&quot; action= &quot;--WEBBOT-SELF--&quot; > </li></ul><ul><li><!--webbot bot=&quot;SaveResults&quot; U-File=&quot;fpweb:///_private/form_results.txt&quot; </li></ul><ul><li>S-Format=&quot;TEXT/CSV&quot; S-Label-Fields=&quot;TRUE&quot; --> </li></ul><ul><li><p><input type= &quot;submit&quot; value= &quot;Submit&quot; name= &quot;B1&quot; ><input type= &quot;reset&quot; value= &quot;Reset&quot; name= &quot;B2&quot; ></p> </li></ul>
    37. 37. Using ASP Pages to Process User Input From HTML Forms <ul><li>Sent Your Form Data to colors.asp, So Now We Need a file called colors.asp … </li></ul><ul><li>We gathered the Following Information From the User: MyFavoriteColor </li></ul><ul><li>We Need a Way to Do Something With MyFavoriteColor -- Enter VBScript Variables </li></ul>
    38. 38. What are Variables? <ul><li>“ A variable is a section of memory that is allocated a name by the programmer. These sections of memory can be used to store pieces of information that will be used in the program. Think of variables as you might think of boxes. They're simply containers for information that you wish to store.” </li></ul><ul><ul><li>From Beginning Active Server Pages </li></ul></ul>
    39. 39. Using Variables in an ASP Page <ul><li>Here is the Code for colors.asp: </li></ul><ul><li><HTML> </li></ul><ul><li><H1> So Your Favorite Color is </li></ul><ul><li><% </li></ul><ul><li>Dim strFavColor </li></ul><ul><li>strFavColor=Request.Form(&quot;MyFavoriteColor&quot;) </li></ul><ul><li>Response.Write strFavColor </li></ul><ul><li>%> ! </li></ul><ul><li></H1> </li></ul><ul><li></HTML> </li></ul>
    40. 40. Another Example of Form Input: The Need to Normalize Data <ul><li>Use of Drop Down Menu to Give User Choices For Data Entry/Selection </li></ul><ul><li>Form Tags are </li></ul><ul><li><FORM ACTION=choosing.asp METHOD=POST> </li></ul><ul><li><SELECT name= choice> </li></ul><ul><li><OPTION selected>First Choice<OPTION> </li></ul><ul><li><OPTION>Second Choice</OPITON> </li></ul><ul><li></SELECT> </li></ul><ul><li></FORM> </li></ul><ul><li>Need to Send This to script.asp for processing … </li></ul>
    41. 41. Creating the ASP Page To Handle Drop-Down Menu Items <ul><li>choosing.asp contains the following code: </li></ul><ul><li>Option Explicit </li></ul><ul><li><% </li></ul><ul><li>Dim strChoice </li></ul><ul><li>strChoice = Request.Form(“choice&quot;) </li></ul><ul><li>Response.Write strChoice </li></ul><ul><li>%> </li></ul><ul><li>This will print the choice your user made on the drop-down menu page </li></ul>
    42. 42. Hands-On Exercise 1: Download and Install Sample Code <ul><li>Download and Install Examples From Wrox.com Site </li></ul><ul><li>Access Zipped Archive of All Code From Beginning Active Server Pages </li></ul><ul><li>Direct URL is: </li></ul><ul><li>http://www. wrox .com/Store/Download.asp?Code=1347 </li></ul>
    43. 43. Hands-On Exercise 2: Forms and ASP <ul><li>View Samples From Chapter 3 </li></ul><ul><ul><li>Forms: </li></ul></ul><ul><ul><ul><li>Department Affiliation Form </li></ul></ul></ul><ul><ul><ul><li>Get Jacket Information Form </li></ul></ul></ul><ul><ul><li>Corresponding ASP Code </li></ul></ul><ul><ul><ul><li>Registration of Department Reply </li></ul></ul></ul><ul><ul><ul><li>Jacket Order Confirmation </li></ul></ul></ul><ul><li>Modify the Above Code to Normalize the Data With Drop-Down Menus </li></ul>
    44. 44. Naming Variables in VBScript <ul><li>Limit is 255 characters </li></ul><ul><li>All variable names must begin with an alphabetical character </li></ul><ul><li>V ariable names must not contain an embedded period/full-stop </li></ul><ul><li>VBScript is not case-sensitive! (Remember that JScript/JavaScript is case sensitive) </li></ul>
    45. 45. VBScript Variables and Variants <ul><li>Most programming languages allow you to declare data types for your variables </li></ul><ul><li>VBScript has only one type, called the variant </li></ul><ul><li>Variants come in a number of different subtypes: numeric, string, date, boolean and special (empty, NULL and object) </li></ul>
    46. 46. Use of Operators in VBScript <ul><li>Assignment </li></ul><ul><li>Comparison </li></ul><ul><li>Logical </li></ul><ul><li>Arithmetic </li></ul><ul><li>Concatenating </li></ul>
    47. 47. String Manipulation in VBScript <ul><li>Len </li></ul><ul><li>Left </li></ul><ul><li>Right </li></ul><ul><li>Mid </li></ul><ul><li>InStr </li></ul><ul><li>Ltrim, Rtrim and Trim </li></ul>
    48. 48. Arrays in VBScript <ul><li>The Purpose of Arrays </li></ul><ul><li>Array Declaration </li></ul><ul><li>Dim StudentsInClass(7) </li></ul><ul><li>Array Redeclaration </li></ul><ul><li>Redim StudentsInClass(8) </li></ul><ul><li>Redim Preserve StudentsInClass(8) </li></ul><ul><li>Mulit-Dimensional Arrays </li></ul>
    49. 49. Hands-On Exercise 3: Strings and Arrays in VBScript <ul><li>Examples From Chapter 4 </li></ul><ul><ul><ul><li>Using a TypeName to Return a Variant Subtype </li></ul></ul></ul><ul><ul><ul><li>Using Variants to Perform a Calculation </li></ul></ul></ul><ul><ul><ul><li>Converting a Variant Example </li></ul></ul></ul><ul><ul><ul><li>String Manipulation Example </li></ul></ul></ul><ul><ul><ul><li>Creating Local Variables Example </li></ul></ul></ul><ul><ul><ul><li>Setting Up an Array Example </li></ul></ul></ul>
    50. 50. What We Accomplished This Morning in Part I <ul><li>Introduced the Course </li></ul><ul><li>Discussed client side/server side scripting </li></ul><ul><li>Introduced Active Server Pages (ASP) </li></ul><ul><li>Explained what platforms these scripts run on and which browsers can see the results </li></ul><ul><li>Discussed configuration of development and production ASP environments </li></ul><ul><li>Discussed the structure of an ASP page </li></ul><ul><li>Introduced VBScript, the default scripting language for ASP </li></ul>
    51. 51. What We Accomplished This Morning in Part II <ul><li>Reviewed Use of Forms </li></ul><ul><li>Introduced ASP Basics: HTML Forms and Variables With VBScript </li></ul><ul><li>Downloaded and Installed Sample Code From Wrox.com </li></ul><ul><li>Worked on Forms-based Examples </li></ul><ul><li>Discussed VBScript Variables in Depth </li></ul><ul><li>Discussed Strings and Arrays </li></ul><ul><li>Worked on String Manipulation/Array Examples </li></ul>
    52. 52. Reference Materials in Parts I & II <ul><li>Beginning Active Server Pages 2.0 </li></ul><ul><ul><li>Chapter 1 “Getting Started With ASP” and </li></ul></ul><ul><ul><li>Chapter 2 “Client-Side Scripting and Server-Side Scripting” </li></ul></ul><ul><ul><li>Chapter 3 “Basic ASP Techniques” </li></ul></ul><ul><ul><li>Chapter 4 “ASP Variables” </li></ul></ul><ul><ul><li>Chapter 5 “Control Constructs” </li></ul></ul><ul><li>Microsoft’s Scripting Technologies Site </li></ul><ul><li>http://msdn.microsoft.com/scripting/ </li></ul><ul><li>VBScript Resources at This Site </li></ul>
    53. 53. <ul><li>ASP Docs on Your IIS Server: </li></ul><ul><li>http://your_server/iishelp/iis/misc/default.asp </li></ul><ul><ul><ul><li>Scripter’s Reference </li></ul></ul></ul><ul><ul><ul><li>Object, Global, Component and Programmer’s Refs </li></ul></ul></ul><ul><li>Activeserverpages.com </li></ul><ul><ul><li>http://www. activeserverpages .com </li></ul></ul><ul><li>MSDN Web Workshop </li></ul><ul><ul><li>Formerly “Site Builder Workshop” http://msdn.microsoft.com/workshop/ </li></ul></ul><ul><ul><li>Select: Server Technologies/Active Server Pages </li></ul></ul>Reference Materials Used in Parts I & II (Cont.)
    54. 54. Lunch Break Take 45 Minutes to Eat!
    55. 55. Active Server Pages: Part III Topics: “Flow Control in VBScript” “ASP Objects” and “The Visual InterDev 6.0 IDE”
    56. 56. <ul><li>Discuss Flow Control in VBScript </li></ul><ul><li>Work on Flow Control Examples With VBScript and ASP </li></ul><ul><li>Discuss the ASP Object Model </li></ul><ul><li>Work on Object Examples With ASP Object Model </li></ul><ul><li>Introduce Visual InterDev 6.0 Integrated Development Environment </li></ul>Goals For Part III
    57. 57. What We Covered Right Before Lunch <ul><li>Reviewed Use of Forms </li></ul><ul><li>Introduced ASP Basics: HTML Forms and Variables With VBScript </li></ul><ul><li>Downloaded and Installed Sample Code From Wrox.com </li></ul><ul><li>Worked on Forms-based Examples </li></ul><ul><li>Discussed VBScript Variables in Depth </li></ul><ul><li>Discussed Strings and Arrays </li></ul><ul><li>Worked on String Manipulation/Array Examples </li></ul>
    58. 58. What is Flow Control? Action vs. Control Statements <ul><li>“ Action statements: Statements that perform an activity, such as the creation of a part of a page, a change to a variable, a redirection to another page, or changing a setting on the server. </li></ul><ul><li>Control statements: Statements that give ASP instructions on which statements to execute, and in what order” </li></ul><ul><ul><li>From Beginning Active Server Pages </li></ul></ul>
    59. 59. Types of Control Structures <ul><li>Branching </li></ul><ul><ul><li>If … Then </li></ul></ul><ul><ul><li>Select … Case </li></ul></ul><ul><li>Looping </li></ul><ul><ul><li>For … Next </li></ul></ul><ul><ul><li>For Each … Next </li></ul></ul><ul><ul><li>Do While </li></ul></ul>
    60. 60. If … Then … Else <ul><li>Used to select one of two sets of lines to execute. </li></ul><ul><li>Also used for complicated comparisons, such as expressions using the terms and, or, not. </li></ul><ul><li>Part of If Then Else: An expression: that is, a test that gives a true or false answer; An &quot;if tru e&quot; section of code; An &quot;if fals e&quot; section of code; An ending statement </li></ul>
    61. 61. Flow Control Walkthrough 1: TioIfThenOneForm.asp <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>Spring Retreat Form</TITLE> </li></ul><ul><li></HEAD> </li></ul><ul><li><BODY> </li></ul><ul><li><H1>Corporate Retreat Registration</H1> </li></ul><ul><li><H3>To get the logistics information </li></ul><ul><li>for your meeting please answer these two questions.</H3> </li></ul><ul><li><FORM ACTION=&quot;TioIfThenOneResponse.asp&quot; METHOD=&quot;post&quot;> </li></ul><ul><li>Please type your preference in month, either March or April:<BR> </li></ul><ul><li><INPUT TYPE=&quot;text&quot; NAME=&quot;MonthPref&quot;><P> </li></ul><ul><li>Please type your preference in location, either East or West:<BR> </li></ul><ul><li><INPUT TYPE=&quot;text&quot; NAME=&quot;Location&quot;> </li></ul><ul><li><BR><BR> </li></ul><ul><li><INPUT TYPE=&quot;submit&quot;> <INPUT TYPE=&quot;reset&quot;> </li></ul><ul><li></BODY> </li></ul><ul><li></HTML> </li></ul>
    62. 62. Flow Control Walkthrough 1 Cont.: TioIfThenOneForm.asp <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>Spring Retreat Response</TITLE> </li></ul><ul><li></HEAD> </li></ul><ul><li><BODY> </li></ul><ul><li><% </li></ul><ul><li>varMonthPref = Request.Form(&quot;MonthPref&quot;) </li></ul><ul><li>varLocation = Request.Form(&quot;location&quot;) </li></ul><ul><li>Response.Write &quot;<H1>Corporate Retreat Registration <BR>Your Details</H1>&quot; </li></ul><ul><li>If varMonthPref=&quot;March&quot; Then </li></ul><ul><li>Response.Write &quot;Your meeting will be held on March 15th &quot; </li></ul><ul><li>Else </li></ul><ul><li>Response.Write &quot;Your meeting will be held on April 16th &quot; </li></ul><ul><li>End If </li></ul><ul><li>If varLocation=&quot;East&quot; Then </li></ul><ul><li>Response.Write &quot;in Myerstown, Pennsylvania&quot; </li></ul><ul><li>Else </li></ul><ul><li>Response.Write &quot;in Malibu, California&quot; </li></ul><ul><li>End If </li></ul><ul><li>%> </li></ul><ul><li></BODY> </li></ul><ul><li></HTML> </li></ul>
    63. 63. Select … Case <ul><li>Used anytime you need to make a choice among several answers (more than just True and False) then use Select Case . </li></ul><ul><li>The syntax for Select Case has four parts: State which variable to test; State a possible answer and what to do if that answer is correct; Repeat for as many possible answers as you want to handle; End the Select Case control structure </li></ul>
    64. 64. Flow Control Walkthrough 2: TioSelectOneForm.asp <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>Spring Retreat Form</TITLE> </li></ul><ul><li></HEAD> </li></ul><ul><li><BODY> </li></ul><ul><li><H1>Corporate Retreat Registration</H1> </li></ul><ul><li><H3>To get the logistics information </li></ul><ul><li>for your meeting please answer these two questions.</H3> </li></ul><ul><li><FORM ACTION=&quot;TIOSelectOneResponse.asp&quot; METHOD=&quot;post&quot;> </li></ul><ul><li>Please type your preference in month, either March or April:<BR> </li></ul><ul><li><INPUT TYPE=&quot;text&quot; NAME=&quot;MonthPref&quot;><P> </li></ul><ul><li>Please type your preference in location, either East or West:<BR> </li></ul><ul><li><INPUT TYPE=&quot;text&quot; NAME=&quot;Location&quot;> </li></ul><ul><li><BR><BR> </li></ul><ul><li><INPUT TYPE=&quot;submit&quot;> </li></ul><ul><li><INPUT TYPE=&quot;reset&quot;> </li></ul><ul><li></BODY> </li></ul><ul><li></HTML> </li></ul>
    65. 65. Flow Control Walkthrough 2 Cont.: TioSelectOneResponse.asp <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>Corporate Retreat Response</TITLE> </li></ul><ul><li></HEAD> </li></ul><ul><li><BODY> </li></ul><ul><li><% </li></ul><ul><li>varMonthPref = Request.Form(&quot;MonthPref&quot;) </li></ul><ul><li>varLocation = Request.Form(&quot;Location&quot;) </li></ul><ul><li>Response.Write &quot;<H1>Corporate Retreat Registration <BR> Your Details</H1>&quot; </li></ul><ul><li>Select Case varMonthPref </li></ul><ul><li>Case &quot;march&quot; </li></ul><ul><li>Response.Write &quot;Your meeting will be held on March 15th &quot; </li></ul><ul><li>Case &quot;March&quot; </li></ul><ul><li>Response.Write &quot;Your meeting will be held on March 15th &quot; </li></ul><ul><li>Case &quot;april&quot; </li></ul><ul><li>Response.Write &quot;Your meeting will be held on April 16th &quot; </li></ul><ul><li>Case &quot;April&quot; </li></ul><ul><li>Response.Write &quot;Your meeting will be held on April 16th &quot; </li></ul><ul><li>End Select </li></ul><ul><li>If varLocation=&quot;East&quot; then </li></ul><ul><li>Response.Write &quot;in Myerstown, Pennsylvania&quot; </li></ul><ul><li>Else </li></ul><ul><li>Response.Write &quot;in Malibu, California&quot; </li></ul><ul><li>End If </li></ul><ul><li>%> </li></ul><ul><li></BODY> </li></ul><ul><li></HTML> </li></ul>
    66. 66. Types of Looping Statements: For…Next; For … Each … Next; Do …While <ul><li>“ ForNext is used to repeat line(s) when, at the beginning of the </li></ul><ul><li>repetitions, we know exactly how many repetitions we want. For </li></ul><ul><li>example, if we know there are five reviewers we could repeat </li></ul><ul><li>five times the set of steps that adds and formats a comment form.” </li></ul><ul><li>ForEachNext is used to repeat line(s) one time for each item in a </li></ul><ul><li>collection. For example, if there are 6 items in a collection, then </li></ul><ul><li>the lines will be executed 6 times. The difference between this </li></ul><ul><li>and ForNext is that you don’t have to know how many items </li></ul><ul><li>there are when you write it.” </li></ul><ul><li>DoWhile is used to repeat line(s) when we don't know how many </li></ul><ul><li>repetitions we want. DoWhile will repeat lines as long as a </li></ul><ul><li>specified condition is tru e.” </li></ul><ul><ul><li>From Beginning Active Server Pages </li></ul></ul>
    67. 67. Flow Control Walkthrough 3: TioForNextOneForm.asp <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>TIO For Next One Form</TITLE> </li></ul><ul><li></HEAD> </li></ul><ul><li><BODY> </li></ul><ul><li><H2>Weekly Client Contacts</H2><BR> </li></ul><ul><li><FORM ACTION=TioForNextOneResponse.asp METHOD = post> </li></ul><ul><li><P>Please enter the first day of the week in the form mm/dd/yy such as </li></ul><ul><li>09/20/98 <BR> </li></ul><ul><li><INPUT TYPE=text NAME=&quot;start&quot;> </li></ul><ul><li><P>Please enter the last day of the week in the same form<BR> </li></ul><ul><li><INPUT TYPE=text NAME=&quot;end&quot;><BR> </li></ul><ul><li><INPUT TYPE=submit> </li></ul><ul><li><INPUT TYPE=reset> </li></ul><ul><li></BODY> </li></ul><ul><li></HTML> </li></ul>
    68. 68. Flow Control Walkthrough 3 Cont.: TioSelectOneResponse.asp <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>TIO ForNext One Response</TITLE> </li></ul><ul><li></HEAD> </li></ul><ul><li><BODY> </li></ul><ul><li><H2>Weekly Client Contacts for George Washington</H2><BR> </li></ul><ul><li><% </li></ul><ul><li>varStart=Request.Form(&quot;start&quot;) </li></ul><ul><li>varEnd=Request.Form(&quot;end&quot;) </li></ul><ul><li>varStart = cdate(varStart) </li></ul><ul><li>varEnd = cdate(varEnd) </li></ul><ul><li>varNumberDays=(varEnd-varStart) </li></ul><ul><li>For varLineCounter = 0 to varNumberDays </li></ul><ul><li>Response.Write &quot;Clients: ___________________&quot; </li></ul><ul><li>Response.Write &quot;<BR ><BR><BR>&quot; </li></ul><ul><li>Next </li></ul><ul><li>%> </li></ul><ul><li>signed _________________________ </li></ul><ul><li>George Washington </li></ul><ul><li></BODY> </li></ul><ul><li></HTML> </li></ul>
    69. 69. Hands on Flow Controls <ul><li>Modify the TioIfThenOne set of examples to Make the Event Occur in the Winter </li></ul><ul><li>Modify the TioSelectOne set of examples to Make the Event Occur in the Winter </li></ul><ul><li>Try TioForNextOneForm.asp and </li></ul><ul><li>TioForNextOneResponse.asp as a Winter Event! </li></ul><ul><li>Modify the TioForNextOne set of examples to Make This an Attendance Report for This Class </li></ul>
    70. 70. Write One Time, Run Many Times: Code Reuse in ASP <ul><li>Within A Single ASP Page, May Need to Insert Some Code in a Number of Places </li></ul><ul><li>May Have the Need to Have Code Do Something and then Give the Results to another Part of the Page For Processing </li></ul><ul><li>Enter Procedures: Subs and Functions </li></ul>
    71. 71. What Are ASP Procedures? <ul><li>“ Subprocedures carry out an action: for example, a Sub would be used to carry out the actions of putting text onto a page </li></ul><ul><li>Functions carry out action statements and return an answer to your code: a function would be used to calculate a delivery date and return that answer to your main program” </li></ul><ul><ul><li>From Beginning Active Server Pages </li></ul></ul>
    72. 72. Creating a Sub <ul><li>3 Parts of a Procedure </li></ul><ul><ul><li>The procedure’s nam e </li></ul></ul><ul><ul><li>The code that the procedure should execute </li></ul></ul><ul><ul><li>An ending statemen t. </li></ul></ul><ul><ul><li>In addition you will have to direct your main body of code to actually run the procedure. </li></ul></ul>
    73. 73. ASP Subprocedure Example: SubExample.asp
    74. 74. ASP Function Example: TioFunctionForm.asp <ul><li><HTML> </li></ul><ul><li><HEAD> </li></ul><ul><li><TITLE>TIO Function Form</TITLE> </li></ul><ul><li></HEAD> </li></ul><ul><li><BODY> </li></ul><ul><li><H2>Cost Calculator for<BR> </li></ul><ul><li>Attendance at Corporate Conference</H2> </li></ul><ul><li>Please provide the following information so we can estimate your </li></ul><ul><li>local costs while attending the conference </li></ul><ul><li><FORM ACTION=&quot;TioFunctionResponse.asp&quot; METHOD=post> </li></ul><ul><li>Please type your preference in location, either city or suburb: </li></ul><ul><li><INPUT TYPE=text NAME=&quot;location&quot;><BR> </li></ul><ul><li><INPUT TYPE=submit> </li></ul><ul><li><INPUT TYPE=reset> </li></ul><ul><li></BODY> </li></ul><ul><li></HTML> </li></ul>
    75. 75. ASP Function Example: TioFunctionResponse.asp
    76. 76. Use of Objects in ASP <ul><li>Objects </li></ul><ul><li>Methods </li></ul><ul><li>Properties </li></ul><ul><li>Events </li></ul><ul><li>Encapsulation </li></ul><ul><li>The Object Model </li></ul>
    77. 77. About Visual InterDev 6.0 <ul><li>Microsoft’s Integrated Development Environment for Web Development </li></ul><ul><li>Microsoft’s Suggested Development Environment for Active Server Pages </li></ul><ul><li>Part of Visual Studio 6.0 or Stand-Alone Professional Version </li></ul><ul><li>Tight Integration With FrontPage For Design and Content Management </li></ul><ul><li>Works With FP 2000 Server Extensions for Remote Management of Coding Projects </li></ul>
    78. 78. Visual InterDev 6.0 Walkthrough <ul><li>Setting Up and Configuring the Client and Server Environments </li></ul><ul><li>The Concept of “Projects” (Like FP “Webs”) </li></ul><ul><li>“ Project Management”: Developing in Master and Local Modes (Working Copies) </li></ul><ul><li>The Authoring Environment, Like FP Editor </li></ul><ul><ul><li>Three Views: Design, Source, Quick View </li></ul></ul><ul><ul><li>Highlight on Source View: Color Coding and Pull Right Options </li></ul></ul><ul><ul><li>Development Environment: Toolbox, Project Explorer, Task List </li></ul></ul>
    79. 79. Getting Visual InterDev 6.0 <ul><li>Trial Version Available for Download (Times Out) </li></ul><ul><li>InterDev 6.0 is Part of Visual Studio 6.0 </li></ul><ul><li>InterDev 6.0 Stand Alone Professional Version Available at Academic Price: $99 </li></ul><ul><li>Pro Version Consists of the Following: </li></ul><ul><ul><li>Server Tools: Part of Option Pack </li></ul></ul><ul><ul><li>Client Tools: Authoring Environment and Limited Source Control </li></ul></ul><ul><ul><li>Manual </li></ul></ul><ul><ul><li>Also Comes With NT Workstation Bundled! </li></ul></ul>
    80. 80. Class Break Take 15 Minutes to Stretch!
    81. 81. Active Server Pages: Part IV Topics: “The ASP Object Model in Depth” and “ASP Components”
    82. 82. <ul><li>Review Object-Oriented Programming Concepts and Explain the ASP Object Model </li></ul><ul><li>Discuss ASP Request and Response Objects </li></ul><ul><li>Discuss ASP Application and Session Objects </li></ul><ul><li>Work on Object Examples With VBScript and ASP, Both As Walkthroughs and as Hands-on Exercises </li></ul><ul><li>Discuss ASP Components </li></ul><ul><li>Work on ASP Components Examples , Both As Walkthroughs and as Hands-on Exercises </li></ul>Goals For Part IV
    83. 83. Object-Oriented Programming <ul><li>Some Key Terms </li></ul><ul><ul><li>Instance </li></ul></ul><ul><ul><li>Properties </li></ul></ul><ul><ul><li>Methods </li></ul></ul><ul><ul><li>Events </li></ul></ul><ul><li>Key Questions: </li></ul><ul><ul><li>What is Encapsulation? </li></ul></ul><ul><ul><li>What are Synchronous and Asynchronous Events? </li></ul></ul>
    84. 84. The ASP Object Model: Three Levels <ul><li>Page Level Objects </li></ul><ul><ul><li>Request </li></ul></ul><ul><ul><li>Response </li></ul></ul><ul><li>Application Level Objects </li></ul><ul><ul><li>Application </li></ul></ul><ul><ul><li>Session </li></ul></ul><ul><li>Server Object: Components </li></ul><ul><li>Ch. 6 Walkthrough ASPs Using MyTelephone.exe Program </li></ul>
    85. 85. Page-Level Objects: The Request Object <ul><li>Collections </li></ul><ul><ul><li>QueryString </li></ul></ul><ul><ul><li>Form </li></ul></ul><ul><ul><li>ServerVariables (role of browscap.ini file) </li></ul></ul><ul><ul><li>Cookies </li></ul></ul><ul><ul><li>ClientCertificate </li></ul></ul><ul><li>Properties and Methods: TotalBytes Property and BinaryRead Method </li></ul><ul><li>Ch. 7 Walkthrough of RequestForm.asp (Put), RequestQuery.asp (Get), browser-os.asp and ServVars.asp </li></ul>
    86. 86. Page-Level Objects: The Response Object <ul><li>Write and Redirect Methods </li></ul><ul><li>The Response.write Shortcut </li></ul><ul><li>Buffer Property: The Role of the Output Buffer </li></ul><ul><li>Flush, Clear and End Methods </li></ul><ul><li>2 More Properties for the Response Object: Expires and ExpiresAbsolute </li></ul><ul><li>Ch. 8 Walkthroughs for Buffer Control, Browser Redirection (BufferOutput.asp;PageChoice.html, choosePage.asp, Page1.html and Page2.html) </li></ul>
    87. 87. Application-Level Objects: The Application Object <ul><li>Challenge of Maintaining State </li></ul><ul><li>Virtual Directories Considered Applications </li></ul><ul><li>Role of the global.asa file </li></ul><ul><li>Scope – Application vs. Session </li></ul><ul><li>Application Object Collections: Contents and StaticObjects </li></ul><ul><li>Using the Lock and Unlock Methods </li></ul><ul><li>Chapter 9 Walkthrough for creation of a global.asa file (p. 262 and 267) </li></ul>
    88. 88. Application-Level Objects: global.asa in Detail <ul><li>Event Handling Subroutines: </li></ul><ul><ul><li>Application_OnStart </li></ul></ul><ul><ul><li>Application_OnEnd </li></ul></ul><ul><ul><li>Session_OnStart </li></ul></ul><ul><ul><li>Session_OnEnd </li></ul></ul>
    89. 89. Application-Level Objects: The Session Object <ul><li>Defining a Session </li></ul><ul><li>Why would this be “the most powerful object in Active Server Pages”? </li></ul><ul><li>Session Shortcut Annotation (p. 272) </li></ul><ul><li>Collections: Contents and StaticObjects </li></ul>
    90. 90. Application-Level Objects: The Session Object (Cont) <ul><li>Session Object Properties include: </li></ul><ul><ul><li>SessionID (careful not to use w/db apps.) </li></ul></ul><ul><ul><li>Timout (Need to test for ave. user time) </li></ul></ul><ul><ul><li>CodePage and LCID </li></ul></ul><ul><li>Session Object Methods: Abandon </li></ul><ul><li>Walkthrough Chapter 9 Exercise SessionVarTest.asp (See pp. 275-278) </li></ul><ul><li>Using global.asa </li></ul>
    91. 91. Using Cookies in ASP <ul><li>Difference Between Session-Level Variables and Cookies? </li></ul><ul><li>Period of Persistence: Set the Date </li></ul><ul><li>Walkthrough the Using ASP Cookies Example From Chapter 9 (see pp 286-292) </li></ul>
    92. 92. Hands-On Exercise: Working With Page and Application-Level Objects <ul><li>Exercise Files For Work With ASP Objects Taken From Chapters 6-9 in Beginning Active Server Pages 2.0 </li></ul><ul><li>Run the Chapter 8 Exercise that Combines the Request and Response Objects: FormExample.html and FormExample.asp (For Text Reference See pp. 248-257) </li></ul><ul><li>Run the Chapter 9 Exercise That Does Visitor Tracking: Create global.asa and VisitorCount.asp (For Text Reference see pp 280-4) </li></ul>
    93. 93. ASP Components and Sever Objects <ul><li>ASP Components are Server-Level Objects That are Instantiated in Your Code in Order For You to Access Them </li></ul><ul><li>Syntax is as follows: </li></ul><ul><li><% </li></ul><ul><li>Set objInstanceName = Server.CreateObject(“ClassName.ComponentName”) </li></ul><ul><li>%> </li></ul>
    94. 94. Default Components Using Visual InterDev 6.0 <ul><li>Drag and Drop Objects </li></ul><ul><li>Location: In Toolbox, Under Server Objects </li></ul><ul><li>Some Server Objects/Components Included: </li></ul><ul><ul><li>Ad Rotator </li></ul></ul><ul><ul><li>Browser Capabilities </li></ul></ul><ul><ul><li>Content Linking </li></ul></ul><ul><ul><li>Script Objects: Dictionary and Filesystem Objects </li></ul></ul>
    95. 95. Hands-On Exercises: Trying Out ASP Components <ul><li>Exercise Files For This Part’s Work With ASP Components Taken From Chapter 12 in Beginning Active Server Pages 2.0 </li></ul><ul><li>Work With Ad Rotator and Content Linker </li></ul><ul><li>A Word on the Browser Capabilities Component and Try the Browser Capabilities Component and Use it in Your Own Page to Test It’s Functionality </li></ul>
    96. 96. Active Server Pages: Part V Topics: “ASP Scripting Objects” “Debugging” and “ASP Data Store Connectivity Using ADO Components”
    97. 97. Goals For Part V <ul><li>Finish Coverage of Built-in ASP Component Examples </li></ul><ul><li>Briefly Cover the ASP Scripting Objects </li></ul><ul><li>Discuss Debugging Using Simple Text Editor, MS Script Debugger and Visual InterDev 6.0 </li></ul><ul><li>Review ODBC and OLE-DB Data Source Basics </li></ul><ul><li>Discuss ASP ActiveX Data Objects (ADO) </li></ul><ul><li>Work on ADO Examples: Connect To MS Access Database Using ADO </li></ul><ul><li>Discuss Issues in Scaling to MS SQL Server: How to Begin Planning a Smooth Upgrade Path </li></ul><ul><li>Where Do We Go Now? </li></ul>
    98. 98. Trying Out ASP Components <ul><li>Exercise Files From Part IV Work With ASP Components Taken From Chapter 12 in Beginning Active Server Pages 2.0 </li></ul><ul><li>Work With Ad Rotator and Content Linker </li></ul><ul><li>A Word on the Browser Capabilities Component </li></ul><ul><li>Try the Browser Capabilities Component and Use it in Your Own Page to Test It’s Functionality </li></ul>
    99. 99. ASP Scripting Objects <ul><li>Dictionary Object Allows You To Store Keyed Values </li></ul><ul><li>FileSystemObject and FileSystemObject Collections: Manipulate Views of File System, etc. </li></ul><ul><li>Server-Side Include (SSI) Object Lets You Reuse the Code You Write </li></ul><ul><li>TextStream: A Particularly Useful Example in the “ASP Source Code Viewer,” a.k.a. DisplaySource.asp (pp. 356 Have a Look!) </li></ul>
    100. 100. Basic Debugging Tips: Using A Text Editor and a Browser <ul><li>Use Option Explicit to Force Variable Declaration </li></ul><ul><li>Code Re-usage </li></ul><ul><li>Client vs. Server-Side Debugging </li></ul><ul><li>Don’t Be Obscure When Naming Variables </li></ul><ul><li>Comment Your Code and Then Comment Your Code Some More … </li></ul>
    101. 101. Debugging Under Win 32: MS Script Debugger & VI 6.0 <ul><li>Dearth of Robust Debugging Tools. </li></ul><ul><li>Yet, Script Debugger Does Offer Some Conveniences: </li></ul><ul><ul><li>Call Stack, Running Documents and Command Windows all Appear Cascaded (See pp. 387) </li></ul></ul><ul><ul><li>Running Documents Window Separates IE and ASP-Based Scripts (Client and Server-Side Differentiated For You) </li></ul></ul><ul><li>Visual InterDev Allows for Remote Host Debugging, So You Can Debug Right on the Server </li></ul>
    102. 102. What and How You Connect: Data Stores and Connections <ul><li>Database as subset of Data Store. </li></ul><ul><li>Connection Links ASP Page to the Data Store </li></ul><ul><li>Data Source Name (DSN) is a Named Connection to a Data Store </li></ul><ul><li>Generated Through the Microsoft ODBC Data Source Administrator </li></ul>
    103. 103. The ODBC Data Source Administrator
    104. 104. Setting Up ODBC Access: 4 Steps to Creating a DSN <ul><li>Step 1: Select ODBC From the Control Panel </li></ul><ul><li>Step 2: Select Add From the System DSN Panel </li></ul><ul><li>Step 3: Select MS Access From the List of Drivers on the Create New Database Source Panel and then Click on the Finish Button </li></ul><ul><li>Step 4: Type in a Data Source Name and Description, Select the Database and then Click on the ok button </li></ul>
    105. 105. Adding a Data Source Name (DSN) STEP 1 STEP 2 STEP 3 STEP 4
    106. 106. Using the DSN in ASP Code <ul><li>DSN Resides on the Server Where the ASP Code Runs (Implications For Develop Locally/Serve Centrally) </li></ul><ul><li>Example of Simple DSN Usage Using Contact.mdb and Contact.asp from the Wrox Site (pp. 404-5) </li></ul><ul><li>Behind the Scenes: OLE-DB communicates with ODBC Drivers, Adds a Layer Between ActiveX and the Data Store </li></ul>
    107. 107. ActiveX Data Object Component <ul><li>ADO is the “friendly face of OLE-DB” </li></ul><ul><li>Superset of DAO (Data Access Objects) and RDO (Remote Data Objects) </li></ul><ul><li>Using ADO Can Use DSN-Less Connection Strings, Which Allows You to Use an SSI (pp.409-411) </li></ul>
    108. 108. What We Accomplished This Afternoon in Part III <ul><li>Reviewed Pre-Lunch Discussion </li></ul><ul><li>Discussed Flow Control in VBScript </li></ul><ul><li>Worked on Flow Control Examples With VBScript and ASP </li></ul><ul><li>Discussed the ASP Object Model </li></ul><ul><li>Worked on Object Examples With ASP Object Model </li></ul><ul><li>Introduced Visual InterDev 6.0 Integrated Development Environment </li></ul>
    109. 109. <ul><li>Reviewed Object-Oriented Programming Concepts and Explain the ASP Object Model </li></ul><ul><li>Discussed ASP Request and Response Objects </li></ul><ul><li>Discussed ASP Application and Session Objects </li></ul><ul><li>Worked on Object Examples With VBScript and ASP, Both As Walkthroughs and as Hands-on Exercises </li></ul><ul><li>Discussed ASP Components </li></ul><ul><li>Worked on ASP Components Examples, , Both As Walkthroughs and as Hands-on Exercises </li></ul>What We Accomplished This Afternoon in Part IV
    110. 110. <ul><li>Finished Coverage of Built-in ASP Component Examples </li></ul><ul><li>Briefly Covered the ASP Scripting Objects </li></ul><ul><li>Discussed Debugging Using Simple Text Editor, MS Script Debugger and Visual InterDev 6.0 </li></ul><ul><li>Reviewed ODBC and OLE-DB Data Source Basics </li></ul><ul><li>Discussed ASP ActiveX Data Objects (ADO) </li></ul><ul><li>Worked on ADO Examples: Connect To MS Access Database Using ADO </li></ul><ul><li>Discussed Issues in Scaling to MS SQL Server: How to Begin Planning a Smooth Upgrade Path </li></ul><ul><li>Next … Where Do We Go Now? </li></ul>What We Accomplished This Afternoon in Part V
    111. 111. Where Do We Go From Here? <ul><li>Read Beginning Active Server Pages 2.0 </li></ul><ul><li>Consider More SQL Readings </li></ul><ul><li>Forge Ahead With the Wrox Press Books! </li></ul>
    112. 112. <ul><li>Beginning Active Server Pages 2.0 </li></ul><ul><ul><li>Chapter 6 “Objects, Properties, Methods and Events” </li></ul></ul><ul><ul><li>Chapter 7 “The Request Object” </li></ul></ul><ul><ul><li>Chapter 8 “The Response Object” </li></ul></ul><ul><li>Microsoft’s Public NNTP Server: </li></ul><ul><ul><li>msnews.microsoft.com </li></ul></ul><ul><ul><li>Also available through DejaNews and Talkway </li></ul></ul><ul><ul><li>Browse the microsoft.public hierarchy for scripting, ASP and IIS discussion groups </li></ul></ul>Reference Materials Used in Part III
    113. 113. <ul><li>Beginning Active Server Pages 2.0 </li></ul><ul><ul><li>Read Chapter 9 “Applications, Sessions and Cookies” </li></ul></ul><ul><ul><li>Read Chapter 10 “Active Server Pages Components” </li></ul></ul><ul><ul><li>Skim Chapter 11 “The Scripting Objects” </li></ul></ul><ul><ul><li>Skim Chapter 12 “Debugging ASP” </li></ul></ul><ul><ul><li>Carefully Read Chapter 13 “Databases With ASP” </li></ul></ul><ul><li>Cyscape, Inc. Site For the Latest on browscap.ini: </li></ul><ul><ul><li>http://www.cyscape.com/browscap/ </li></ul></ul>Reference Materials Used in Parts IV and V
    114. 114. Web Development Resources Indexes <ul><li>Yahoo </li></ul><ul><ul><li>http://dir.yahoo.com/Computers_and_Internet/Internet/World_Wide_Web/ </li></ul></ul><ul><li>Netscape DevEdge </li></ul><ul><ul><li>http://developer. netscape .com/ </li></ul></ul><ul><li>Sun’s JavaSoft </li></ul><ul><ul><li>http://java.sun.com </li></ul></ul><ul><li>Microsoft’s Developer Network </li></ul><ul><ul><li>http://www. microsoft .com/ sitebuilder / </li></ul></ul>http://www. njin .net
    115. 115. What We Accomplished Today <ul><li>Reviewed MS FrontPage 2000’s Basic Features and Began to Utilize it as a development environment for advanced Web design. </li></ul><ul><li>Learned practical skills to enhance your institutions' Web sites. </li></ul><ul><li>Learned about ODBC connectivity for dynamic database driven web sites </li></ul><ul><li>Learned about Visual InterDev. </li></ul>http://www. njin .net
    116. 116. For Further Information <ul><li>See the Seminar Site at: </li></ul><ul><li>http://www.clioweb.net/mdobe/teaching/1999/NJIN-ITP/ </li></ul><ul><li>Feel Free to Contact the Instructor </li></ul><ul><ul><li>E-mail: [email_address] </li></ul></ul>http://www. njin .net

    ×