- Shopping Bag ( 0 items )
With Active Server Pages For ...
With Active Server Pages For Dummies in hand, you'll become a pro at developing exciting, dynamic Web pages for the Internet or for your own company intranet. Using Microsoft's ActiveX Data Objects to access and manipulate database information simplifies the nightmare of online database management by enabling you to use down-to-earth commands and controls. And you can use Active Server objects to work with forms, access cookies, dynamically change the content of your HTML pages, share information among people visiting your site, and much, much more!
Active Server Pages For Dummies has a surefire way to perk up your Web sites, too: a bonus CD-ROM packed with all the source code from the book, Microsoft's latest Internet Explorer 4.01, HomeSite 3 (an HTML editor that works great for creating ASP pages), and Chili!ASP, an add-on that allows non-Microsoft Web servers to use Active Server Pages technology.
I find the "Dummies" and "Idiots" series thoroughly repugnant, and have always been resolved that I would never give any of these titles free publicity with a review. Each "Dummies" book spits in the reader's eye with the title on the cover, and then continues to insult the reader's intelligence from the first page to the last with inappropriate familiarity, dorky jokes and cartoons, lame puns, and hackneyed subheadings. Since when is the reader a "Dummy" or an "Idiot" just because he or she wishes to learn more about a topic? (Though I must admit that the book "Windows-95 for Dummies" did give me a few chuckles... the title had a certain inner truth that I'm sure was completely lost on the publisher.)
So here you find me, in an inexplicable turn of events, reviewing Active Server Pages for Dummies. To what shall you attribute this wanton betrayal of a deeply-felt credo, this spineless surrender to the forces of the Dark Side, this embrace of the precipitous decline of Western Civilization, this abandonment of the inmost self to the inexorable disintegration of traditional moral values? The main reason is that most of the other introductory books on Active Server Pages are so poorly written that a book called Active Server Pages for Dummies can actually look pretty good by comparison. As a consolation prize, it gives me an opportunity to bash the publishers about the ears a bit.
Aside from the obnoxious and sophomoric attempts at humor, this book is basically sound and delivers the most value among the entry-level books on ASP that I have encountered thus far. Programmers should bypass this book and go directly to Wrox Press's Professional Active Server Pages 2.0.--Dr. Dobb's Electronic Review of Computer Books
- I Know Who You Are....
Why Active Server Pages?
How This Book Is Organized
- Part I: Getting Started
Part II: Speaking Like a Native
Part III: Getting to Know Your Objects
Part IV: Accessing the Database
Part V: Really Cool ASP Applications
Part VI: The Part of Tens
Part VII: Appendixes
- ASP Me (No) Questions....
On the CD
Chapter 1: So What's an Active Server Page?
Boring, Dumb, Static HTML
Forms and CGI
ASP as Easy as 1, 2, 3
What Does an ASP Page Look Like?
How Is ASP Different from Client-Side Scripting?
How Is ASP Different from ActiveX Controls and Java Applets?
The World of Internet Development
Chapter 2: Just How Easy Is ASP?
Everything You Need to Get Started
About Your Language, Young Man....
No Development Environment? What a Pain in the ASP!
Creating and Testing Your ASP Pages
- Where to work
We're clear for liftoff: Creating the launch page
- Get Your ASP in Gear: Creating Your First ASP Page
Modifying, Retesting, Creating New Pages, and Converting Old Pages
How Does It Work?
Chapter 3: Understanding VBScript Basics
Getting Started with Programming and Scripting
- What is a programming language?
What is a scripting language?
What are all of those strange words?
- Power -- In Time....
Delimiters -- Keeping Your Tags and Your Code Apart
Keep Your Comments to Yourself
Up Your Case!
As I Was Saying: Line Continuation
Creating and Using Variables
- Making your own variables with objects you can find around the house
Can you use a variable you didn't create?
Forcing the point
Displaying variable values
Don't string me along....
- Cantankerous Constants
How Functions Function or How to Get a
Let the Arguments Commence!
Rolling Dice and Cutting Cards -- Using Functions in Formulas with
Common Commands and Functions
Other math functions
- String Manipulation
- FormatCurrency, FormatDateTime, FormatNumber, FormatPercent
LTrim, RTrim, Trim
Left, Mid, Right
- Dates and Times
- Date, Time, Now
Other Date/Time Functions
Chapter 4: Real VBScript Programming
Decisions, Decisions, Decisions: Using
- IF you want cool Web pages THEN use conditionals
Inequalities: A fact of life
Lies! All lies! Or...what to do if it isn't true
Developing your nesting instincts
- Get Off My Case!
When Should You Use Select Case Instead of
Loop the Loop
- Counting with
Watch where you Step
Exit, stage left
For Each..Nextwith arrays
- Creating Your Own Subroutines and Functions
- Creating subroutines
A better random number function
Calling subroutines and functions
Chapter 5: JScript for Geeks
Who Should Read This Chapter?
What Is JScript?
JScript and ASP
Picking your parlance, locating your language, choosing your chatter
- Here's What You Can't Do
- No compiler
No structures or unions
No classes or inheritance
No operator overloading
No variable number of arguments
- One Thing You Can (Finally!) Do: Strings
Be Gentle. He's Case Sensitive.
The Terminator (Of Lines)
Variable Vagrants and Smooth Operators
- I declare! These variables have no type!
Types for the typeless
Scoping it out
Casting out the demons of coercion
Operator? I'd like to make a call....
- Conditionals and Loops
for..next, while, do..while
Chapter 6: Objects, Objects Everywhere!
Okay, So What's an Object?
Getting the Patter Down
Using Scripting Objects
- To err is human....
Other VBScript-specific scripting objects
- Arrays as objects as arrays as....
Strings as objects
Converting a string to upper or lower case
Finding the index of a string within a string
- Scripting Objects Available to Both VBScript and JScript
- What's a
Dictionary? Look It Up!
Creating a Dictionary in VBScript
Creating a Dictionary in JScript
Getting drive info with VBScript
Show files in root in VBScript
Islands in the
Start up the
ScriptEngine...we're goin' to town!
Chapter 7: Using Server Objects
An Application, or Just a Bunch of Pages?
Using ASP Server Objects
The input object:
Accessing cookie values
The output object: Response
- The application and session events
Creating objects in
- Server-Side Includes
- How to do it
What it's good for
Chapter 8: Creating ASP Applications
Creating New Web Applications
- Creating new Web applications with PWS
Creating new Web applications with IIS
Your Web application's Default page
- A Guest Book: Creating and Responding to Forms
- The Default page
The Guest Book form
Responding to the form
Listing the visitors
- Creating a Radio: Music to Surf By
- Creating the MIDI music
The Default page
The Radio page
The Tuning page
- A Personalized Welcome Page with Cookies
- Changing the Guest Book form
Changing the Guest Book processing page
Changing the Listing page
The new Default page
- Customizing a Page Based on the Date
Web Site Roulette with
The Power of ASP
Chapter 9: Using the Included Server Components
A Rose by Any Other Name...Is Confusing!
So What Is a Server Component?
The Components Included with Your Server
Browser Performance Anxiety
- Creating a new server component object
The other way to create a new server component object
Putting the Browser Capabilities Component to work
The inside story: How the Browser Capabilities Component works its magic
- Just What the World Needs: More Advertising
- The rotator schedule file
Using the Ad Rotator Component
- That Fresh Site Feeling with the Content Rotator
- The content schedule file
Using the Content Rotator Component
- Linking Your Content
The Tools of the Trade
Counting Page Hits
Counting Other Things
Remembering Who You Are with MyInfo
A Whole World of Server Components
Chapter 10: Accessing a Database from ASP
Creating a New Database and Table
For the Do-It-Yourselfer
YAMA: Yet Another Mysterious Acronym -- Creating an ODBC DSN
- What's ODBC?
What's an ODBC Data Source Name?
How do I create a DSN?
- SMMA: Still More Mysterious Acronyms -- Using the DAC to Get to Your ADO
Including ADO Constants
Connecting to a Database
From the Database to the Web Page
- Executing SQL
Displaying the results
- Getting Exactly the Information You Want
- Today's menu
Planning for the next few days
Chapter 11: Updating the Database
Diving Deeper with the
- Opening a
Connect, disconnect, connect, disconnect -- is this really a good idea?
Cursors and other people with soapy mouths
Freely moving around a
Holding your place with bookmarks
Change your data filters at least twice a year
Recordsetproperties and methods
- Updating the Database
- Putting your records in a headlock
Editing and updating records
Adding new records
- Catching Database Errors
Error handling tips
Chapter 12: The Café: Creating a Real-Time Chat Room
The Blueprint for the Café
- Sharing information between visitors
Updating the browsers with new information
Putting together the pieces
- Building the Café, Brick-by-Brick
- The login page:
The frames page:
Displaying the conversation:
Who's here? Find out with
- Playing in the Café
Making It Better
Chapter 13: Classy Classifieds
Planning to Create Classy Classifieds
- What classified ad categories will I use?
What pages will I need?
What technical issues are left?
- The Home Page:
The Header Include File:
Adding An Ad:
The Category Listing:
Displaying the Details:
Confirming the User:
Editing an Ad:
Deleting an Ad:
Searching for Ads:
Displaying the Results of a Search:
Making It Better
Chapter 14: The Ten Best Places to Look When You Have a Question
RTFM: Read the Flippin' Manual!
Magazines and Newsletters
Online Forums and Web Sites
Microsoft Web Technical Support
Microsoft Telephone Support
Chapter 15: The Ten Coolest Web Sites for ASP Developers
The EdgeQuest Active Web Site
The Official Microsoft SiteBuilder Network
Windows NT ActiveX Server Bulletin Board
The ASP Hole
ASP Developers Site
ASP Developers Network
Online Version of WebWeek Newspaper
Chapter 16: Ten Interesting Things That Server Components Can Do for You
Make It Easy to Send and Receive E-Mail from ASP
- Mail Components
- xPop3 and xSMTP
- Managing Files
- Execute Applications from ASP
- ASPExec 2.0
- Make Money with Internet Commerce
- Access Information on Your UNIX, AS/400, or Mainframe Computer
- ARPEGGIO Live!
- Charting and Reporting
- Chart FX Internet Edition
Chili!Reports Enterprise Edition
- Accept Database Queries in English
- English Wizard Web/Server
- Browsing from the Server
- Other Interesting Stuff
- AspBible Bible Component
- Appendix A: Introducing Microsoft Visual InterDev
Features of Visual InterDev
How Is Visual InterDev Different from Microsoft FrontPage?
Creating a Quick Classy Classifieds
- Creating the Classy Project and Workspace
Adding a database connection
Trying it out
- Appendix B: A Crash Course in Database Basics
What's a DBMS? What's a Database?
Tables, Rows, and Columns
Primary Keys and Surrogate Keys
Relationships between Tables
Speaking Database-ese: SQL
Appendix C: Creating Databases and Tables in Microsoft Access
- Creating the database
Creating a new table
Entering data into the new table
- Appendix D: About the CD
In This Chapter
What's the big deal about ASP? It doesn't really let you do anything you couldn't already do before, right? So why bother learning yet another new thing? There are way too many new things to figure out already!
To answer these questions, in this chapter I show you what your non-ASP options are for creating interactive Web pages. Then I show you exactly what ASP is all about and how it works.
Think about how a simple Web page works.
lotsoffun.comand finds the actual server machine on the Internet.
This is how the World Wide Web was originally conceived. A pretty simple idea. But it provided for a very easy way to access information and gave the page designer quite a bit of flexibility in laying out a page.
But the communication for static HTML works only one way. There is no way to send information back to a Web server. To fix this problem, forms and CGI were created. Forms are HTML tags that allow Web page creators to include controls like edits, check boxes, and radio buttons in their Web pages. That way, the user can enter information. It also provides a Submit button that sends the information off to the server.
But now the server has to be smarter, too. It can't just get requests for pages and send out pages. The server has to know what to do with this form information when it gets it. That's where CGI comes in.
CGI stands for Common Gateway Interface. CGI makes it possible for the Web server to talk to another application that can handle the form information when it's sent back. Often these CGI applications are written in a language called Perl. When the CGI application receives the form information, it can save it to a text file, store it in a database, or do whatever else the Web site administrator wants it to do.
This system works great for simple guest books and the like. But if you want to make your Web pages really interactive, you may start running into trouble.
The problem with CGI is that if five people are submitting form information at the same time, five different copies of the CGI application have to be running on the server to handle them. If a hundred people are submitting form information at once -- you guessed it! -- a hundred copies of the application run at the same time. This is a great way to make a popular Web server fall to its knees and crawl.
Because of the problems with CGI forms slowing everything down, server APIs were born. API stands for Application Programming Interface. Microsoft's server API is called ISAPI. It stands for the Internet Server Application Programming Interface (clever, no?).
Like CGI, ISAPI allows the Web server to communicate with other applications running on the server machine. But ISAPI is much more efficient than CGI. It doesn't launch a separate program each time someone sends back information from a form. And it allows the application developer a lot more flexibility in how the server responds to the browser.
But ISAPI doesn't solve all the problems. You still have to write separate computer programs that have complex interfaces to your Web server and that work closely with your Web pages. ISAPI isn't very intuitive, and it's difficult to create and maintain. Because of these problems, few businesses go to the trouble of creating truly engaging, interactive Web sites. Creating great Web sites with ISAPI just takes too much time, and most companies can't afford to dedicate a group of expensive programmers to the task of making their Web sites really, really cool.
Active Server Pages (ASP) solves all the problems associated with CGI and server APIs. In addition to being just as efficient as ISAPI applications, ASP is simple to learn and easy to use.
With CGI or ISAPI, you had to write a computer program in a language like Perl or C that had complex interface code connecting it to the server. Then you had to compile the application and associate it with the appropriate Web pages.
With ASP, you simply write your code in the HTML page itself. The HTML tags and the code are side by side. You write the code in a simple scripting language that is easy to learn and easy to use. Then you save the page to your Web site and it's ready to go. No compiling and no complex interfacing!
As you can imagine, ASP makes it much quicker and easier to create highly interactive Web sites. It also makes your pages easier to maintain and update in the future.
So what happens when an ASP page is requested by the browser? It works like this:
.aspextension, instead of an
This arrangement has lots of advantages:
Say it again, with redundancy
You may have noticed that I occasionally refer to an "ASP page." You're probably saying to yourself, "Now wait a minute. Isn't that an Active Server Pages page?" My response: "Yup. It shore is."
You see, when I was on my pilgrimage to the English Gurus, I asked them about the redundancy of "ASP page." This is what they said: Since ASP refers to a technology, the phrase "Active Server Pages page" is, in fact, correct, and not redundant at all. The first "Page" is part of the phrase which describes the technology. The second "page" is the actual noun you're talking about. The Gurus never lie.
If you're like me, you can only hear someone describe something for so long before you want to see it yourself. The code below shows you what a real, live ASP page looks like.
<title>My Home Page</title>
<h1>My Home Page</h1><p>
<% If Time >= #12:00:00 AM# And _
Time < #12:00:00 PM# Then %>
<h2>Good Morning! </h2><p>
<% ElseIf Time >= #12:00:00 PM# And _
Time < #6:00:00 PM# Then %>
<h2>Good Afternoon! </h2><p>
<% Else %>
<h2>Good Evening! </h2><p>
<% End If %>
<h2>I'm happy you could stop by...</h2><p>
Most of this should look familiar. I've identified a title for the page and used a first level head to display My Home Page at the top. But then comes the weird part. What are
%>? In ASP these are called \delimiters. They set off the code from the rest of the HTML tags. That way you'll always know which is which. If it is inside the \delimiters, you know its code. Otherwise, it's got to be HTML.
It's not too hard to guess how this page works, even if you haven't done much computer programming. This code is written in VBScript and is very English-like.
Time is a VBScript function that returns the current time (on the server's system clock).
So first I check to see if the time is between 12:00 a.m. and 12:00 p.m. If it is, the HTML after the
Then is sent back to the browser:
<h2>Good Morning! </h2><p>
A note for client-side scripters
Also note that there is no reason to use the HTML comments (
The next line is a continuation of the
If..Then statement. It begins
ElseIf. In other words, "If that didn't work, try this." It checks to see if the time is after 12:00 p.m. and before 6:00 p.m. If it is, this HTML is sent back to the browser:
<h2>Good Afternoon! </h2><p>
Else is a catchall. If none of the other conditions worked, send this HTML back to the browser:
<h2>Good Evening! </h2><p>
End If lets you know that the
If..Then statement is over. The next line of HTML is displayed, no matter how the
If..Then condition worked out:
<h2>I'm happy you could stop by...</h2><p>
Notice that five lines of HTML are in the page. The first and last are always displayed. But only one of the middle three is displayed, depending on the time. Suppose the time is 7:00 p.m. and you go to this page. Your screen would look like Figure 1-1.
If you chose View-->Source from the Internet Explorer menu, you'd see the HTML below.
<title>My Home Page</title>
<h1>My Home Page</h1><p>
<h2>Good Evening! </h2><p>
As you can see, all the VBScript code has been stripped out. And only the appropriate HTML line in the
If..Then statement was sent. From looking at this, you'd have no idea that this was anything more than a simple HTML page that always says
For more information on
If..Then and all the other VBScript commands, see Chapters 3 and 4.
Client-side scripting works a little differently:
Client-side scripting and server-side scripting are similar in that they both allow you to write code right alongside your HTML and have that code executed when the page is requested. And often you can do the same thing using either client-side scripts or server-side scripts. There are some important differences, though.
The good news is that you don't have to pick between client-side scripting and server-side scripting. You can use both! Even in the same page. In fact, there are some techniques for using them together that are very effective.
For instance, imagine you are selling music CDs from your Web site. The user fills out a form to order three CDs. He has to give his name, address, phone number, social security number, and so forth. When the user clicks the button to submit the form, you use a client-side script to check to make sure that he's filled in all the information. You can even check the phone number and social security number to make sure the number of digits is correct. When everything looks good, then you can send it off to the server. After it gets to the server, you can use an ASP page to save the order in your database.
Of course, you could check to make sure everything was filled in and looked good in your ASP page. But that means the user would have to wait for the bad data to be sent to the server, evaluated, and a message returned to the browser. Doing all that stuff on the client-side, before the data is sent, is much quicker and makes a lot more sense.
You don't have to read much about the Internet before you see the words Java and ActiveX kicked around. They are two of the hottest topics in the Web development world. How is ASP different?
The concept of Java applets was created by Sun Microsystems. ActiveX controls were created by Microsoft. Both are small programs that are downloaded as part of a page, just as a graphic would be. But when they are received by a client machine, they are executed in the browser and the result is displayed on the Web page. Simple ActiveX controls or Java applets may provide a control that the user can use to enter information, like a listbox. More complex controls or applets may allow you to explore 3-dimensional VRML worlds, or view an animation, or see live video as it is broadcast from a Web site.
Client-side scripts are often used to coordinate several controls or applets on the page so that they work together. Using these technologies together, you can create something that works like a multimedia application or a game.
Java applets are written in Java, and ActiveX controls can be written by using Visual Basic, C/C++, Java, or other languages. They allow the site developer to create complex programs that couldn't be created by using scripting alone.
You may wonder, if there are controls and applets that supplement scripts on the client-side, are there also controls or applets on the server-side that supplement ASP? The answer is yes. Server components are the topic of Chapter 9.
The Internet is still a very young platform for application development. The growth of interest in the Internet, both for personal and professional use, has been staggering. This interest is bound to make the Internet a central focus of almost all major new development in the future.
But today we're still in the early stages, and the standards and development environments and tools aren't nearly as well-defined as they are for stand-alone application software like word processors and spreadsheets. This is both good news and bad news. The pioneers always have the biggest opportunity to leave their mark on the future. But they also often have to work with very crude tools.
ASP, Java, and ActiveX are the forerunners of the tools of the future, and they are the tools that will begin to turn the promise of a truly exciting, interactive Internet into a reality.