charles e. brown imar spaanjaars todd marks c1€¦ · beginning dreamweaver mx. and . fireworks...
TRANSCRIPT
-
Beginning Dreamweaver® MX 2004
Charles E. BrownImar Spaanjaars
Todd Marks
C1.jpg
-
Beginning Dreamweaver® MX 2004
-
Beginning Dreamweaver® MX 2004
Charles E. BrownImar Spaanjaars
Todd Marks
-
Beginning Dreamweaver®MX 2004Published byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com
Copyright © 2004 by Wiley Publishing, Inc. All rights reserved.
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any formor by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except aspermitted under Section 107 or 108 of the 1976 United States Copyright Act, without either the priorwritten permission of the Publisher, or authorization through payment of the appropriate per-copy feeto the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax(978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal Department,Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317)572-4447, E-mail: [email protected].
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: WHILE THE PUBLISHER AND AUTHORHAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK, THEY MAKE NO REPRESENTA-TIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THECONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OFMERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BECREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS. THEADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR YOUR SITUA-TION. YOU SHOULD CONSULT WITH A PROFESSIONAL WHERE APPROPRIATE. NEITHERTHE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHERCOMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CON-SEQUENTIAL, OR OTHER DAMAGES.
For general information on our other products and services please contact our Customer Care Depart-ment within the United States at (800) 762-2974, outside the United States at (317) 572-3993 or fax (317)572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in printmay not be available in electronic books.
Library of Congress Control Number is available from the publisher.
ISBN: 0-7645-5524-3
Printed in the United States of America
10 9 8 7 6 5 4 3 2 1
Trademarks Acknowledgments
Wiley, the Wiley Publishing logo, Wrox, the Wrox logo, the Wrox Programmer to Programmer logoand related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc., and/or itsaffiliates in the United States and other countries, and may not be used without written permission.Dreamweaver is a registered trademark of Macromedia, Inc. All other trademarks are the property oftheir respective owners. Wiley Publishing, Inc., is not associated with any product or vendor men-tioned in this book.
www.wiley.com
-
About the Authors
Charles E. BrownCharles E. Brown, Ph.D., is a noted author and teacher in the computer industry today. His first twobooks, Beginning Dreamweaver MX and Fireworks MX: From Zero to Hero, have received critical acclaimand are consistent best-sellers. He is also releasing books on VBA for Microsoft Access and on MicrosoftFrontPage 2003. He is also a Fireworks MX contributor for the MX Developer’s Journal.
In addition to his busy writing schedule, Charles conducts frequent seminars for Learning TreeInternational and the PC Learning Center. His topics include Java programming, using Dreamweaver,and the Microsoft Office environment.
Charles is also a noted classical organist, pianist, and guitarist who studied with such notables asVladimir Horowitz, Virgil Fox, and Igor Stravinsky. It was because of his association with Stravinskythat he got to meet, and develop a friendship with, famed 20th-century artist Pablo Picasso.
Charles can be contacted through his Web site at www.charlesebrown.net.
I would like to thank Andy Nosalskiy at www.dreamweaverdesk.com for his invaluable assistancein designing great Dreamweaver templates.
Imar SpaanjaarsImar Spaanjaars graduated in Leisure Management at the Leisure Management School in TheNetherlands but accidentally ended up in Information Technology (IT). After working for a large corpo-ration and doing some freelance work, he is now working in the software development department of asmall IT company in The Netherlands that specializes in Internet, intranet, and wireless applications. Asa software architect and lead developer, he’s responsible for designing, building, and implementingmedium- to large-scale intranets and wireless solutions. His current project involves the design andimplementation of an application that allows employees to connect to enterprise data in real-time whileon the road using a Pocket PC running the .NET Compact Framework.
When he is not busy writing software or teaching other people how to do so, Imar likes to read as muchas possible about new developments in the software industry. He’s a fanatic squash player and enjoysplaying 3D shoot-’em-up games if he’s got the time for it.
Imar lives in Utrecht, The Netherlands. You can contact him at [email protected].
I would like to thank the people at Wrox for making this project possible. I would especially like to thankBrian MacDonald and Meryl K. Evans for their efforts during the editorial process.
I would also like to thank my parents, Jos and Bep, for the inspiration and motivation they have givenme over the years.
Finally, I would like to thank my girlfriend, Fleur, for her love and her support during this project.
-
Todd MarksTodd Marks is an avid developer, designer, instructor, and author of information display technologies. In2000 Todd moved from teaching mathematics and computer science in the public sector to becoming VPof Research and Development at digitalorganism (www.digitalorganism.com). In 2002 Toddfounded information technologies portal MindGrub Technologies (www.mindgrub.net). Todd cur-rently works as a multimedia engineer for the MediaEdge division of Exceptional Software(www.media-edge.com). You can contact him at [email protected].
Todd has worked extensively with ActionScript, ASP, PHP, Lingo, and numerous other development lan-guages, placing cutting-edge code in several projects. Todd’s efforts have earned three Flash Film Festivalnominations, a Macromedia Site of the Day, two ADDY Awards, and several educational partnerships.Todd is a Macromedia Certified Developer, Designer, and Subject Matter Expert, and has written and con-tributed to several books, including Flash MX Video, Foundation Dreamweaver MX, Beginning DreamweaverMX, Advanced PHP for Flash MX, Flash MX Most Wanted Components, and Flash MX 2004 Magic.
I would like to thank everyone at MediaEdge and Exceptional Software for their support. I would par-ticularly like to express my love to my wife Betsy and daughters Sadie and Kara.
-
CreditsAuthorsCharles E. BrownImar SpaanjaarsTodd Marks
Vice President and Executive Group PublisherRichard Swadley
Vice President and Executive PublisherRobert Ipsen
Vice President and PublisherJoseph B. Wikert
Executive EditorChris Webb
Development EditorBrian MacDonald
Editorial ManagerMary Beth Wakefield
Executive Editorial DirectorMary Bednarek
Technical EditorMeryl K. Evans
Production EditorWilliam A. Barton
Copy EditorStefan Gruenwedel
Project CoordinatorRegina Snyder
Graphics and Production SpecialistsCarrie FosterLauren GoddardKristin McMullan
Quality Control TechnicianCarl William Pierce
Text Design & CompositionWiley Composition Services
Media Development SpecialistKit Malone
Proofreading and IndexingTECHBOOKS Production Services
-
Introduction
The rise of the Internet over recent years means that, for many of you, Web sites are now part of every-day life. You use them for research, news, purchases, tracking shipments, games, and information. Thereis a huge amount of information out there, and it is growing all the time.
In spite of the volume of information on the Web, and the sheer number of Web sites in existence thesedays, it’s still possible to create a new Web site, get it out there on the Internet, and get it noticed. Ofcourse, it’s a good idea to have something interesting to say on your Web site, but that’s not all — youcan make your Web site attractive with a suitable page design and the appropriate use of features, andyou can make it more functional and useful with the help of some back-end data storage and datamanipulation.
That sounds great in principle, but how can you do it in practice? If you don’t know the basics, then theamount you need to learn about each Web programming language (and how they work together) seemsdaunting. Even if you already know the basics of HTML, JavaScript, Active Server Pages, and so on, it’sstill more practical to use your knowledge to build attractive Web sites quickly and effectively, withoutthe hassle of typing every last line of code.
For both types of Web developer, Macromedia Dreamweaver MX 2004 provides a solution.Dreamweaver is a powerful Web-development tool that helps you create attractive, dynamic, powerfulWeb sites. Its many tools and features not only enable you to create Web pages and Web sites quicklyand painlessly, but they help you structure your Web sites in such a way that they are easy to maintainafter you’ve built them.
If you’re new to the various coding languages of the Web, fear not — Dreamweaver MX 2004 writes mostof the code for you. If you’re familiar with the basics, then Dreamweaver can help you create feature-richWeb sites with considerable ease. It generates the code for you and allows you to change the code it gen-erates so that you have complete control over the final result.
What Does This Book Cover?This book is a practical introduction to Dreamweaver MX 2004. In this book, we will quickly get youused to the features of Dreamweaver. We use step-by-step examples to show you the basics, and alongthe way you build three attractive, functional Web sites.
We also take a look at the code that Dreamweaver generates and explain how it works. This is impor-tant: You can achieve a lot just by using the point-and-click features of Dreamweaver, but you canachieve even more if you have an understanding of what is going on behind the scenes. Therefore, inthis book, we examine both.
-
x
Introduction
How Is This Book Structured?In this book we create three complete Web sites. We use a step-by-step approach to build the sites andexplain each step so that you know what’s going on. We also provide the complete source code for allthree sections at www.wrox.com so that you have the option of building as much as you like of each sitefor yourself, or simply placing the source code on a Web server and watching it work.
Each Web site is quite different in nature and achieves a different purpose. You can use each of the sitesas a basis for your own ideas and, hence, develop them into sites that you will be proud to publish.Briefly, the three Web sites are as follows.
Section 1: The Cooking PlaceIn Section 1 of the book (Chapters 1–6), you create a hobbyist site called The Cooking Place. The purposeof this site is to be a resource for all things culinary: cooking techniques, recipes, equipment, news, andso on. As you build this site, you’ll learn how to use Dreamweaver MX 2004 to do the following:
❑ Plan, create, and set up a Web site
❑ Add Web pages to the site and edit their content
❑ Use style sheets and templates to create a consistent style across the site
❑ Use tables and layers to control the layout of Web pages
❑ Add dynamic effects (like drop-down menus) to Web pages using JavaScript and DHTML
❑ Write a form to enable visitors to submit information and use dynamic ASP Web pages tocapture submitted information and react to it
Section 2: The Soccer SiteAs you progress through the book, the sites become increasingly ambitious. In Section 2 (Chapters 7–13),you build a soccer fan site that provides information on upcoming events for soccer fans around theworld. As you build this site, you’ll see how you can use Dreamweaver to do the following:
❑ Add logic to your ASP pages so that you can display different information to different users(depending on who they are or even what time of day it is)
❑ Keep track of users as they move around the site so that you can find out what parts of yoursite are the most popular
❑ Secure parts of the Web site so that only authorized users are allowed to see sensitiveinformation
❑ Personalize the Web site for individual users so that the site appears in the colors of the user’sfavorite team or that they see only events occurring in their home country
❑ Store and extract information about users and upcoming events in a database and use thisinformation to create Web pages dynamically
-
xi
Introduction
Section 3: MediaEdge and Building BlocksIn Section 3 (Chapters 14–18), you build a site that shows off many of the advanced features ofDreamweaver MX 2004. As you progress through these chapters, you’ll see how to design a modular,extensible, and scalable Web site and create a set of dynamic Building Blocks that you can quicklymodify and reuse in different sites.
As you build this site (which is used to display a set of images that users can view and purchase), you’lllearn how to use Dreamweaver MX 2004 to accomplish the following:
❑ Create a set of Building Blocks whose look and content is determined dynamically by thesettings in a database
❑ Create a content management page that you can use to mange the database that stores informa-tion about the images on the site, including their title, price, and how they should be laid out
❑ Put the Building Blocks you created earlier to a variety of uses, including a news blogger, amedia display, and a product display
❑ Use Dreamweaver extensions to make your Building Blocks easy to reuse and to add e-commerce functionality to the site
The AppendixesAs you work through the book you learn enough about languages such as HTML, JavaScript, andCascading Style Sheets (CSS) to have a good understanding of what Dreamweaver does for you behindthe scenes. This is knowledge that will help you create better, more effective Web sites.
You also learn about server-side Web programming using Active Server Pages (ASP). This is a valuableskill in itself, but this will also prove useful if you plan eventually to build Web sites with JavaServerPages (JSP), ASP.NET, PHP, or ColdFusion MX. Dreamweaver MX 2004 supports all of these server-sideprogramming technologies; indeed, programming in any of these languages is very similar inDreamweaver and the core concepts you learn in building Web sites with ASP are applicable and easilytransferred to other languages. To help, this book includes four appendixes that provide fast-pacedguides on getting started using JSP, ASP.NET, PHP, and ColdFusion MX with Dreamweaver MX 2004.
Why Not Try . . .Each chapter concludes with a Why Not Try . . . section, which suggests tasks and exercises that youmight try, using the concepts and techniques covered in that chapter. They’re designed to help youreinforce the ideas for yourself, or to extend them — and to encourage you to experiment with newfeatures of Dreamweaver and Web site development in general.
Some of the suggestions come with hints for how you should set about the task — but more detailedguides for each can be found at http://p2p.wrox.com/exercises/.
-
xii
Introduction
Who Is This Book For?This book has two primary audiences. If you are new to the world of Web development and you haveaccess to Dreamweaver MX 2004 (or you’re thinking of buying Dreamweaver MX 2004) then you can usethis book to learn about Web site development using Dreamweaver. We’ll show you what to do andyou’ll learn enough about the important topics and about what happens behind the scenes to startcreating attractive, functional Web sites very quickly.
If you’ve already done some Web site programming in the past but you’re new to Dreamweaver (or justnew to the latest version of Dreamweaver), then this book will show you how to achieve the tasksyou’ve been working on, but in far less time and with far fewer bugs! Dreamweaver generates as muchcode as you want it to and it’s a great tool for rapid application development and proof-of-conceptdevelopment.
What You Need for This BookTo build and run the Web sites featured in this book you’ll need the following:
❑ Microsoft Windows 2000 Professional or Server, Windows Server 2003, or Windows XPProfessional Edition
❑ Microsoft Internet Information Services (IIS) 5.0, 5.1, or 6.0, which comes bundled with theoperating systems listed above and which includes the necessary features to run server-sideASP coding
❑ Macromedia Dreamweaver MX 2004
If you don’t already own a copy of Dreamweaver MX 2004, you can download a 30-day evaluation edi-tion from Macromedia at www.macromedia.com/downloads/. The evaluation edition is full-featuredand you’ll be able to use it to work through the examples in the book.
If you have Microsoft Windows 98, Windows XP Home Edition, or Mac OS, you will need access to aremote server in order to run the ASP Web sites in the book. Appendix E and the Dreamweaver HelpDocumentation contain information about setting up a site to work with a remote server.
ConventionsWe use a number of different styles of text and layout in the book to help differentiate between the vari-ous styles of information we provide. Here are examples of the styles we use along with explanations ofwhat they mean.
Try It Out ConventionsThe Try It Out section is an exercise you should work through, following the text in the book.
1. They usually consist of a set of steps.
-
xiii
Introduction
2. Each step has a number.3. Follow the steps through.4. Then read How It Works to find out what’s going on.
How It WorksAfter each Try It Out, the code you’ve typed in will be explained in detail.
Background information looks like this.
Not-to-be-missed information looks like this.
Bulleted information is shown like this:
❑ Important words have a special italic font.
❑ Any code fragments or file names within normal text are highlighted in a special font.
❑ Menu items that require you to click on multiple submenus have a special symbol thatlooks like this: ➪ . For example: File ➪ New ➪ Folder.
Code shown for the first time, or other relevant code, is in the following format:
Dim intVariableintVariable = 10Response.Write(intVariable)
Less important code, or code that you have seen before, looks like this:
intVariable = 10
Customer SupportWe offer source code for download, errata, and technical support from the Wrox Web site atwww.wrox.com. In addition, you can join our mailing lists for author and peer discussions athttp://p2p.wrox.com. (See the last section in this introduction for more info on the P2P site.)
Source Code and UpdatesAs you work through the examples in this book, you may choose either to type in all the code manuallyor use the source code files that accompany the book. All the source code referenced in this book is avail-able for download at www.wrox.com. Once at the site, simply locate the book’s title (either through theSearch utility or by using one of the title lists) and double-click the Download Code link on the book’sdetail page to obtain the source code for the book.
-
xiv
Introduction
ErrataWe have made every effort to ensure that there are no errors in the text or in the code.
To find the errata page for this book, go to www.wrox.com and locate the title using the Search utility orone of the title lists. On the book’s detail page, click the View Errata link. On this page you will be able toview all errata that have been submitted for this book and posted by Wrox editors. You can also click theSubmit Errata link on this page to notify us of any errors you’ve found.
While we’re on the subject of submitting errata, if you find an error in this book we definitely want tohear about it. In addition to the link on the book’s detail page, you can also e-mail the information [email protected]. We’ll check the information and, if appropriate, post a message to the book’serrata page and fix the problem in subsequent editions of the book.
If you do e-mail us, your e-mail should include the following things:
❑ In the Subject field, include the book’s title, the last six digits of the ISBN (555243 for this book),and the page number on which the error occurs.
❑ In the body of the message, include your name, contact information, and the problem.
We won’t send you junk mail. We promise! We need these details to help you as quickly as possible.
E-mail SupportIf you wish to query a problem in the book directly with an expert who knows the book in detail, thene-mail [email protected], giving the title of the book and the last six numbers of the ISBN in theSubject field of the e-mail. A typical e-mail should include the following things:
❑ The title of the book, the last six digits of the ISBN, and the page number of the problem in theSubject field, for example: “Beginning Dreamweaver MX 2004, 555243, Page 42.”
❑ Your name, contact information, and the problem in the body of the message.
When you send an e-mail message, it will go through the following chain of support:
1. Your message is delivered to our customer support staff, who are the first people to read it.They have files on most frequently asked questions and will answer anything general about thebook or the Web site immediately.
2. Deeper queries are forwarded to the technical editors responsible for the book. They have expe-rience with the programming language or particular product and are able to answer detailedtechnical questions on the subject.
3. In the unlikely event that the editors cannot answer your problem, they will forward the requestto the authors. The publisher does try to protect authors from distractions to their writing; how-ever, the editors are quite happy to forward specific requests to them. All Wrox authors supporttheir books. They will e-mail the editor with their responses so that all readers benefit.
-
xv
Introduction
p2p.wrox.comFor author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-basedsystem for you to post messages relating to Wrox books and related technologies and interact with otherreaders and technology users. The forums offer a subscription feature to e-mail you topics of interest ofyour choosing when new posts are made to the forums. Wrox authors, editors, other industry experts,and your fellow readers are present on these forums.
At http://p2p.wrox.com you will find a number of different forums that will help you not only as youread this book, but also as you develop your own applications. To join the forums, just follow these steps:
1. Go to p2p.wrox.com and click the Register link.2. Read the terms of use and click Agree.3. Complete the required information to join as well as any optional information you wish to pro-
vide and click Submit.
4. You will receive an e-mail with information describing how to verify your account and com-plete the joining process.
You can read messages in the forums without joining P2P, but in order to post your own messages, youmust join.
Once you join, you can post new messages and respond to messages other users post. You can read mes-sages at any time on the Web. If you would like to have new messages from a particular forum e-mailedto you, click the Subscribe to this Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to ques-tions about how the forum software works as well as many common questions specific to P2P and Wroxbooks. To read the FAQs, click the FAQ link on any P2P page.
The Wrox support process can support only issues that are directly pertinent to thecontent of your published title. Support for questions that fall outside the scope ofnormal book support is provided by the community lists at http://p2p.wrox.com.
-
Contents
About the Authors vCharles E. Brown vImar Spaanjaars vTodd Marks vi
Introduction ixWhat Does This Book Cover? ixHow Is This Book Structured? x
Section 1: The Cooking Place xSection 2: The Soccer Site xSection 3: MediaEdge and Building Blocks xiThe Appendixes xiWhy Not Try . . . xi
Who Is This Book For? xiiWhat You Need for This Book xiiConventions xii
Try It Out—Conventions xii
Customer Support xiiiSource Code and Updates xiiiErrata xiiiE-mail Support xiv
p2p.wrox.com xvContents xvii
Part I: The Cooking Place 1
Chapter 1: Getting Started with Dreamweaver MX 2004 3
A Brief Overview of Web Technology 4Static Web Pages 4Dynamic Web Content 7
The Macromedia Suite 10Installing Dreamweaver MX 2004 11
Try It Out—Installing Dreamweaver MX 2004 11
Installing a Web Server 14Try It Out—Installing and Testing IIS 5.x 15
-
xviii
Contents
Exploring Dreamweaver MX 2004 19Try It Out—Building Your First Web Page 19
The Dreamweaver Workspace 26Panel Groups and Panels 26The Property Inspector 28The Insert Panel Group 28
Setting up the Preview Browsers 30Try It Out—Configuring Dreamweaver for Browser-Based Page Previews 31
Summary 34Why Not Try . . . 34
Chapter 2: Creating a Web Site 35
Creating Your First Web Site 35Physical Directories and Virtual Directories 36The Site Definition Feature 37
Try It Out—Creating a New Web Site 37
Creating a Web Page 44Try It Out—Creating Your First Web Page 44
Adding Metadata and Header Information 50Try It Out—Adding Metadata to a Web Page 50
Building the Page Design 51The Table Structure 52Browser Compatibility 53Preparing the Workspace 54
Try It Out—Preparing the Workspace 55
Building the Top Table 57Try It Out—Creating an HTML Table 57
Adding Content to the Top Table 60Try It Out—Adding Content to a Table 60
Building the Middle Table 65Try It Out—Building the Middle Table 65
Building the Bottom Table 72Try It Out—Building the Bottom Table 72
Summary 74Why Not Try . . . 75
Chapter 3: Site Structure, Navigation, and Content 77
Site Structure and Navigation 78Expanding the Site 78
Try It Out—Duplicating Files in Dreamweaver 78
-
xix
Contents
Building a Navigation System 79Implementing Navigation Buttons 80
Try It Out—Creating a Navigation System 81
Try It Out—Configuring the Navigation Buttons on news.htm and regions.htm 85
Pop-up Menus 86Behaviors 87
Try It Out—Creating a Pop-up Menu 87
Organizing the Site with the Files Panel 91Site Synchronizing 94The Site Map 95
Tools to Assist the Team 98Check In/Out 98Design Notes 100Managing Links 103Site Reports 104
Adding Content to Pages 106Inserting and Formatting Tables 107
Try It Out—Adding Content to news.htm 107
Inserting Text 113Try It Out—Inserting and Styling Text 114
Inserting Graphics in Text 117Try It Out—Inserting Graphics 117
Adding Links to the Text 122Try It Out—Adding Links 122
Summary 124Why Not Try . . . 125
Chapter 4: Style Sheets and Templates 127
Cascading Style Sheets 128HTML and Structure 128How Styles Works 129CSS Rules 129Creating and Implementing a CSS Style Sheet 130
Try It Out—Creating an External Cascading Style Sheet 130
Adding More Styles to a Style Sheet 134Try It Out—Adding More Styles to the Style Sheet and Linking It to Other Pages 134
Techniques for Inserting CSS 139Editing Styles 140
Try It Out—Creating Embedded CSS 140
CSS Classes 141Try It Out—Using a CSS Class 142
-
xx
Contents
Classes and Logical Markup 144Try It Out—Logical Markup Using CSS Classes 145
Pseudo-Classes and Pseudo-Elements 148Try It Out—Using a Pseudo-Class to Create a Rollover in a Text Hyperlink 149
Templates 151Creating a Template 151
Try It Out—Creating a Dreamweaver Page Template from an HTML File 152
Creating New Pages from a Template 153Try It Out—Creating Pages from a Template 153
Editable and Noneditable Regions 154Editing Template-Based Documents 155
Try It Out—Editing Template-Based Documents 155
Adding a Template After the Fact 159Try It Out—Applying a Template to an Existing Document 159
Breaking the Template Link 161Libraries 161
Try It Out—Working with Library Items 161
Summary 162Why Not Try . . . 163
Chapter 5: Layers, Behaviors, and Dynamic Effects 165
An Overview of Browser Scripting 166Dynamic HTML 166
Try It Out—A JavaScript Demonstration 167
Targeting a Browser 169Attaching Multiple Behaviors to an Element 171
Try It Out—Attaching Multiple Behaviors to a Single Element 171
Layers 173Try It Out—Constructing Layers 173
Hidden Layers 177Try It Out—Controlling Layer Visibility 177
Using Layers to Provide Extra Information 180Try It Out—Attaching a Pop-up Layer to a Hyperlink 181
Swapping Images 186Try It Out—Creating Disjointed Images 186
Using Image Maps with Behaviors 189Try It Out—Image Mapping 190
Summary 193Why Not Try . . . 193
-
xxi
Contents
Chapter 6: User Interaction with ASP and Forms 195
HTML Forms 196Try It Out—Creating a Simple Form 198
The tag 205The tag 205
Sending Form Data to the Server 206Form Validation 207
Try It Out—Setting Up Validation Rules 207
Improving Forms with CSS 209Try It Out—Applying CSS Rules to Forms 209
Introduction to Dynamic Content 211Dynamic Web Pages 211Active Server Pages 214Creating an ASP Page 215
Try It Out—Building Your First ASP Page 215
Using Forms with ASP 218Try It Out—Using Forms with ASP 218
Conditional Output 220Try It Out—Having Your Form Make a Decision 220
Bringing It All Together 221Try It Out—Finishing Up the Cooking Place 222
Summary 225Why Not Try . . . 226
Part II: The Soccer Site 227
Chapter 7: Adding Logic to Your ASP Pages 229
The Sample Site: GlobalSoccerEvents.com 230Creating the Basics of Your Site 232
Try It Out—Creating the Site 232
Creating the Site Structure 235Try It Out—Creating a Template 235
Try It Out—Adding a Menu to Your Template 238
Try It Out—Spicing Up the Template 243
Try It Out—Implementing the Menu as a Library Item 245
Try It Out—Applying the Template 246
Passing Values from Page to Page 248Creating a Form That Uses GET 249
Try It Out—Sending Values with GET 252
Try It Out—Retrieving Values 254
-
xxii
Contents
Sending and Receiving Values Using POST 255Try It Out—Using POST 255
Using Postback to Post Back to the Current Page 256Try It Out—Creating a Calculator Using Postback 256
Using Information on Multiple Pages 260The Session Object 260Enabling Session State 261
Try It Out—Enabling Session State 261
Exploring Session State 263Try It Out—Exploring Session State 264
The Global.asa File 267Try It Out—Adding Code to the global.asa File 267
The Application Object 269Try It Out—Using Application_OnStart 270
Creating a Hit Counter 271Try It Out—Creating a Hit Counter 271
Summary 273Why Not Try . . . 274
Chapter 8: Keeping Track of Users 275
Saving Information About a Page 276Cookies in Detail 276
Try It Out—Saving the Number of Hits to a Page 278
Forewarned Is Forearmed 281Improving the User’s Browsing Experience 284
Try It Out—Creating Intelligent Drop-Down Lists 284
Site Tracking 291Grouping Code Together 291Using Include Files 293Page Monitoring 295
Try It Out—Tracking User Behavior 295
Summary 303Why Not Try . . . 304
Chapter 9: Securing Web Sites 305
Creating a Login Form 306Try It Out—Creating a Login Form 307
Enhancing the Login Form 313Try It Out—Adding Client-Side Validation to the Login Form 313
Try It Out—Adding Style Sheets to Your Login Form 316
-
xxiii
Contents
Protecting Your Pages 324Try It Out—Protecting Your Admin Menu 324
Improving Usability: Using the Referrer 327Try It Out—Redirecting to the Referring Page 328
Preparing for Growth 331Try It Out—Using the FileSystemObject 332
Summary 338Why Not Try . . . 338
Chapter 10: Personalizing Web Sites 341
Using Themes 341Try It Out—Creating Themes 342
Try It Out—Creating changeSiteTheme.asp 348
Remembering the User’s Theme 354Try It Out—Applying the Theme 354
Creating a Custom Color Picker 357Try It Out—Building a Custom Color Picker 358
Changing the Site Badge 365Try It Out—Creating the Country Drop-Down List 366
Try It Out—Changing the Site Badge 370
Try It Out—Finishing the Badge Chooser 375
Summary 380Why Not Try . . . 381
Chapter 11: Getting Information from a Database 383
What Is a Database? 384The Sample Database 387
Different Kinds of Databases 389Securing a Database 390
Try It Out—Restricting Access to the Database 391
Creating a Database-Driven Web Site 396DSN Connection Strings 396
Try It Out—Creating a DSN 396
DSN-less Connection Strings 398Try It Out—Creating a Connection in Dreamweaver MX 2004 399
Enhancing the Login Page 402Try It Out—Making the Login Page Database-Driven 403
Fine-Tuning Access to Your Site with Access Levels 408Try It Out—Applying Access Levels to the login.asp Page 409
Try It Out—Changing the Admin Page So It Uses Access Levels 411
-
xxiv
Contents
Extending Access-Level Functionality 414Try It Out—Protecting Page Regions 414
Summary 419Why Not Try . . . 419
Chapter 12: Retrieving and Displaying Data from Databases 421
Displaying a List of Events 422Try It Out—Making the Events List Database-Driven 422
Try It Out—Displaying the Events on events.asp 425
Extending the Repeat Region 433Filtering Database Values Using a Drop-Down List 433
Try It Out—Filtering the Categories 433
Filtering Values by Date 436Try It Out—A Date with the WHERE Clause 436
Try It Out—Your Second Date with the WHERE Clause 438
Viewing Details of an Event 440Linking the Event List to the Details Page 440
Try It Out—Adding View Event Details Links 441
Showing Details of an Event 443Try It Out—Displaying Details of a Requested Event 443
Adding Error-Handling 448Try It Out—Adding an Error Message 448
Paging Data 451Limiting the Events List 451
Try It Out—Limiting the Number of Events 451
Navigating the Data 452Try It Out—Creating Navigational Links 452
Performance Considerations with Paging Data 455Improving the Navigation System 455
Try It Out—Selectively Displaying the Navigational Links 456
Summary 457Why Not Try . . . 458
Chapter 13: Storing Information in a Database 461
Maintaining Your Events 462Introducing JOINs 463Viewing Available Events 465
Try It Out—Showing a List with Available Events 465
Try It Out—Enhancing Your Dynamic Table 471
Creating New Events 473Try It Out—Modifying the View Events Page 474
-
xxv
Contents
Adding a Simple Insert Form 475Try It Out—Adding the Insert Form 476
Spicing Up the Form 484Try It Out—Adding the Cancel Button 484
Try It Out—Adding Validation 485
Try It Out—Creating a Form Validation Function 486
Changing Existing Events 492Try It Out—The Record Update Form 493
Deleting Events 500Try It Out—Changing the showEvents.asp Page 502
Try It Out—Adding the deleteEvents.asp Page 504
Finishing GlobalSoccerEvents.com 507Summary 508Why Not Try . . . 509
Part III: MediaEdge and Building Blocks 511
Chapter 14: Designing an Effective Site with a Modular System 513
The MediaEdge Web Site 514Overview of Building Block Technology 515
Navigation and Content 516The Layout 518
Creating the MediaEdge Site 520Try It Out—Creating the New Site 521
Creating Index.asp 522Setting Up the Page Properties of Index.asp 523
Try It Out—Setting the Page Properties of Index.asp 523
Adding the Table Layout for the Building Block System 525Try It Out—Creating the Table Layout for Index.asp 525
Adding a Search Field Using Flash MX 2004 527Try It Out—Adding Macromedia Flash Objects in Dreamweaver 527
Creating a New Server Behavior 529Try It Out—Adding a New Server Behavior 529
Implementing the New Server Behavior 531Try It Out—Implementing a Server Behavior 531
Using Images 533Using Cascading Style Sheets 534
Try It Out—Creating the CSS File 534
Summary 537Why Not Try . . . 537
-
xxvi
Contents
Chapter 15: Creating the Building Block 539
The Building Block 540The Building Block Database 541
Creating the Database 541Try It Out—Creating the Sections Table 543
Try It Out—Creating the Content Table 545
Try It Out—Creating the Section_Content Table 546
The Database Connection 547Try It Out—Connecting to the Database from Dreamweaver 548
Using the Database in buildingBlock.asp 549Try It Out—Creating the buildingBlock.asp file 549
Adding a Rollover Image to the Building Block 553Try It Out—Adding a Rollover Image to the Building Block 553
Creating the Building Block Recordset 554Try It Out—Creating the Building Block Recordset 554
Creating a Dynamic Image Server Behavior 556Try It Out—Creating a DynamicImage Server Behavior 556
Making the Building Block’s Images Dynamic 559Try It Out—Making the Building Block’s Images Dynamic 560
Inline Frames 563Try It Out—Creating an iFrame Server Behavior for the Building Block 563
Dynamic Dimensions for the Center Cell 566Try It Out—Giving the Building Block’s Center Cell Dynamic Dimensions 566
Creating Content 568Try It Out—Creating blockContent.asp 568
Summary 573Why Not Try . . . 573
Chapter 16: Creating a Content Management System 575
Updating the Database 576Adding Fields to the Content Table 576
Try It Out—Adding Fields to the Content Table 576
Creating a Subnavigation Table 577Try It Out—Creating a Subnavigation Table 577
Overview of a Content Management System 578Content Creation 579Content Storage 583Permissions Storage 583Content Publishing 585Content Presentation 585
-
xxvii
Contents
Building a Content Management System 586Creating a User Options Page 586
Try It Out—Creating a User Options Page 586
Adding the Edit and Delete Buttons 587Try It Out—Building the Edit Content and Delete Content Functionality 588
Developing a Content Creation Page 590Try It Out—Creating the Content Creation Page 591
Try It Out—Customizing the Form’s Appearance 593
Developing the Content Update Page 595Try It Out—Developing the Content Update Page 595
Try It Out—Removing the ID Field 598
Developing the Content Deletion Page 598Try It Out—Developing the Content Deletion Page 599
Extending the Forms 601Summary 602Why Not Try . . . 602
Chapter 17: Completing the Building Block Structure 603
Block Navigation 604Creating the New Files 606
Try It Out—Creating the blockNav.asp File 606
Using location.replace 611Session Variables 611
Try It Out—Adding a Session Variable 612
Preventing Page Caching 613Try It Out—Preventing a Page from Caching 613
Creating blockMain.asp 614Try It Out—Creating the blockMain.asp File 614
Search Capabilities 617Try It Out—Creating the blockSearch.asp File 618
Adding Content Data 622Adding Content to the Sections Table 622
Try It Out—Adding Content to the Sections Table 624
Adding Content to the Content Table 625Try It Out—Adding Content to the Content Table 625
File Associations 626Try It Out—Adding Associations in the Section_Content Table 626
Try It Out—Adding Associations in the Sections_Nav Table 627
Loading Different Types of Content 628Summary 629Why Not Try . . . 630
-
xxviii
Contents
Chapter 18: Going Beyond with Dreamweaver MX 2004 Extensions 631
Dreamweaver Extensions 631Installing the Extension Manager 632
Try It Out—Installing the Extension Manager 632
Using the Extension Manager 634Extension Format 634Macromedia Exchange for Dreamweaver 636Ratings 637
Adding the PayPal Shopping Cart Extension 638Try It Out—Incorporating E-commerce Functionality in the Building Block Structure 638
Try It Out—Adding Values to the Database Content Table 641
Try It Out—Sign Up for a PayPal Business Account 642
Try It Out—Adding the E-commerce Functionality 643
Try It Out—Adding Dynamic Values 645
Try It Out—Opening PayPal in a New Browser Window 646
Summary 647Why Not Try . . . 648Additional Resources 648
Part IV: Appendixes 651
Appendix A: Using ASP.NET with Dreamweaver MX 2004 653
What You Need 653Setting Up the Site 654Setting Up an ASP.NET Page 656Creating a Database Connection 658If Something Goes Wrong 664Finding .NET Tools 664Further Reading 665
Appendix B: Using PHP and MySQL with Dreamweaver MX 2004 667
What You Need 667Dreamweaver MX 2004 and PHP 668Preparing the Database 668Setting Up the Site 672Setting Up a PHP Page 674Creating a Database Connection 676Finding PHP Tools 680Further Reading 681