544047 fm stripins 5/19/03 2:42 pm page 1 c1...beginning dreamweaver®mx charles brown imar...

30
Beginning Dreamweaver®MX Charles Brown Imar Spaanjaars Todd Marks

Upload: others

Post on 17-Mar-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

  • Beginning Dreamweaver®MX

    Charles BrownImar Spaanjaars

    Todd Marks

    544047 FM stripins 5/19/03 2:42 PM Page 1

    File AttachmentC1.jpg

  • Beginning Dreamweaver®MX

    Charles BrownImar Spaanjaars

    Todd Marks

    544047 FM stripins 5/19/03 2:42 PM Page 1

  • Beginning Dreamweaver®MXPublished byWiley Publishing, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256www.wiley.com

    Copyright © 2003 by Wiley Publishing, Inc., Indianapolis, Indiana

    Published simultaneously in Canada

    Library of Congress Card Number: 2003107081

    ISBN: 0-7645-4404-7

    Manufactured in the United States of America

    10 9 8 7 6 5 4 3 2 1

    1M/QU/QW/QT/IN

    No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by anymeans, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, orauthorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 RosewoodDrive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8700. Requests to the Publisher for permission should beaddressed 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 AUTHOR HAVEUSED THEIR BEST EFFORTS IN PREPARING THIS BOOK, THEY MAKE NO REPRESENTATIONS OR WAR-RANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOKAND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FORA PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTA-TIVES OR WRITTEN SALES MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAYNOT BE SUITABLE FOR YOUR SITUATION. YOU SHOULD CONSULT WITH A PROFESSIONAL WHEREAPPROPRIATE. NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFITOR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL,CONSEQUENTIAL, OR OTHER DAMAGES.

    For general information on our other products and services or to obtain technical support, please contact ourCustomer Care Department within the U.S. at (800) 762-2974, outside the U.S. 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 print may not beavailable in electronic books.

    Trademarks: Wiley, the Wiley Publishing logo, Wrox, the Wrox logo, the Wrox Programmer to Programmer logoand related trade dress are trademarks or registered trademarks of Wiley in the United States and other coun-tries, and may not be used without written permission. All other trademarks are the property of their respec-tive owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.

    544047 FM stripins 5/19/03 2:42 PM Page 2

    www.wiley.com

  • Trademark Acknowledgments

    Wrox has endeavored to correctly render trademarks for all the companies and productsmentioned in this book with the appropriate use of capitals. However, Wrox is unable toguarantee the accuracy of this information.

    Credits

    Authors Technical ReviewersCharles Brown Kirk MontgomeryImar Spaanjaars Chris CraneTodd Marks Brad Maiani

    Sandro TuccinardiAdditional Material Andy Welch

    Andy Welch Meryl K EvansJohn Timney

    Series Editor Graeme BullJohn Collin Mike Perrin

    Commissioning Editor Production CoordinatorDaniel Richardson Neil Lote

    Technical Editors Production AssistantsMike Foster Paul GroveDevin Lunsford Sarah HallIan Nutt

    CoverManaging Editor Natalie O'Donnell

    Laurent LafonProof Reader

    Project Manager Chris SmithNicola Phillips

    IndexJohn Collins

  • About the Authors

    Charles BrownCharles E Brown transferred his creative skills from music – he has a doctorate in music andstudied with Igor Stravinsky (which led to an association with Pablo Picasso) – to computersin 1981. In addition to a busy music schedule, Charles does web design for major corporations,is a busy trainer conducting nearly 100 workshops per year, is a frequent speaker atconferences, and recently released the book Fireworks MX From Zero to Hero for Friends of Edpublishing.

    Charles does software seminars for The PC Learning Center in northern NJ and can be reachedthrough www.pclearningcenter.com.

    I would like to thank Andy Nosalskiy at www.Dreamweaverdesk.com for his invaluableassistance in designing great Dreamweaver Templates.

    Imar SpaanjaarsImar Spaanjaars graduated in Leisure Management but accidentally ended up in IT. Afterworking for a large corporation and doing some freelance work, he is now working at thesoftware development department of a small IT company in the Netherlands specializing inInternet and Intranet applications. As a software architect and lead developer, he's responsiblefor designing, building, and implementing medium to large scaled intranets for Dutch companies.

    When he is not busy building websites, or teaching other people how to do so, he likes to readas much as possible about new developments in software land. He also enjoys playing 3Dshoot-'em-up games if he's got the time for it.

    He currently lives in Utrecht, the Netherlands and you can contact him [email protected].

    I would like to thank the people at Wrox for their support during this project. I wouldespecially like to thank Daniel Richardson and Mike Foster. Couldn't and wouldn't havedone it without you guys!

    I would also like to thank my girlfriend Fleur for her support and attention during thisproject. Finally, I would like to thank Pipok for keeping me company during the long hoursof writing and code debugging.

  • Todd MarksTodd Marks is an avid developer, designer, instructor, and author of information displaytechnologies. In 2000 Todd moved from teaching Mathematics and Computer Science in thepublic sector to VP of R&D at digitalorganism (www.digitalorganism.com). In 2002 Toddestablished an information technologies portal, MindGrub Technologies (www.mindgrub.com)and currently works for the Media Edge division of Exceptional Software(www.exceptionalsoftware.com). Todd has worked extensively with ActionScript, PHP, Lingo,and numerous other development languages, placing cutting-edge code in several projects.Todd's efforts have earned three Flash Film Festival nominations, Macromedia Site of the Day,two Addy Awards, and several educational partnerships. Todd is a Macromedia CertifiedDeveloper, Designer, and Subject Matter Expert, and has contributed to several booksincluding Flash MX Video, Advanced PHP for Flash MX, Foundation Dreamweaver MX, and FlashMX Most Wanted Components.

    I would like to thank Ben Wehling for his work on the MediaEdge website, and the rest of theExceptional Software staff for their support. I would particularly like to express my love to mywife Betsy and daughter Sadie, who I am in debt to for countless lost hours of "family time".

  • Table of Contents

    Introduction 1

    What Does this Book Cover? ....................................................................................2

    Who is this Book For? ..............................................................................................4

    What You Need for this Book....................................................................................5

    Conventions.............................................................................................................5

    Customer Support ....................................................................................................6Errata ...................................................................................................................................................... 6E-mail Support.......................................................................................................................................... 7p2p.wrox.com........................................................................................................................................... 7Why this System Offers the Best Support .............................................................................................................................. 8

    The Cooking Place

    Chapter 1: Getting Started with Dreamweaver MX 11

    A Brief Overview of the Internet ..............................................................................12Static Web Pages and Dynamic Web Pages .............................................................................................. 12Hypertext Markup Language (HTML) .................................................................................................................................... 13

    How the Page Gets to the Browser ...................................................................................................................................... 14Dynamic Web Content......................................................................................................................................................... 16

    Dreamweaver MX...................................................................................................19Installing Dreamweaver MX...................................................................................................................... 19Installing a Web Server ........................................................................................................................... 24Installing Microsoft's IIS Web Server ........................................................................................................ 25Getting Started with Dreamweaver MX...................................................................................................... 29The Dreamweaver Workspace.................................................................................................................. 35Panel Groups and Panels .................................................................................................................................................... 36

    The Property Inspector ........................................................................................................................................................ 37The Insert........................................................................................................................................................................... 38Setting up the Preview Browsers.............................................................................................................. 38

    Summary ...............................................................................................................42

  • Table of Contents

    ii

    Chapter 2: Creating a Website 43

    Creating a Website ................................................................................................ 44Creating a Website in Dreamweaver..........................................................................................................44Physical Directories and Virtual Directories ..........................................................................................................................44The Site Definition Feature ..................................................................................................................................................45

    Creating a Web Page ............................................................................................. 51Adding Metadata and Header Information..................................................................................................56Building our Page Design .........................................................................................................................58The Table Structure.............................................................................................................................................................59Preparing the Workspace.....................................................................................................................................................60

    Building the Top Table.........................................................................................................................................................62Adding Content to the Top Table..........................................................................................................................................66

    Building the Middle Table ....................................................................................................................................................71Building the Bottom Table ...................................................................................................................................................78

    Summary ............................................................................................................... 80

    Chapter 3: Site Structure, Navigation, and Content 83

    Site Structure and Navigation................................................................................. 84Expanding the Site ..................................................................................................................................84Building a Navigation System ...................................................................................................................85Implementing Navigation Buttons ........................................................................................................................................87Pop-up Menus.........................................................................................................................................93Behaviors ...........................................................................................................................................................................94The Site Map ..........................................................................................................................................98Viewing Dependent Files in the Site Map ...........................................................................................................................100

    Adding Content to Pages ..................................................................................... 101Inserting Text and Graphic Combinations ................................................................................................107Inserting Graphics into the Text .........................................................................................................................................111Adding Links to the Text ....................................................................................................................................................116

    Summary ............................................................................................................. 119

    Chapter 4: Stylesheets and Templates 121

    Cascading Style Sheets ....................................................................................... 122How CSS Works ....................................................................................................................................123CSS Rules ........................................................................................................................................................................124Creating and Implementing a CSS Stylesheet.....................................................................................................................124

    Adding More Styles to a Stylesheet ...................................................................................................................................129Techniques for Inserting CSS .................................................................................................................134Cascading ........................................................................................................................................................................136CSS Classes.........................................................................................................................................139Classes and Logical Markup..............................................................................................................................................142Pseudo-Classes and Pseudo-Elements....................................................................................................146

  • Table of Contents

    iii

    Templates ...........................................................................................................150Creating a Template.............................................................................................................................. 150Creating New Pages from a Template ..................................................................................................... 152Editable and Non-editable Regions .................................................................................................................................... 153

    Editing Template-based Documents................................................................................................................................... 153

    Libraries ..............................................................................................................158

    Summary .............................................................................................................161

    Chapter 5: Using Layers and Frames for Layout 163

    Frames and Framesets .........................................................................................164How Framesets Work ............................................................................................................................ 164A Frameset-based Solution ............................................................................................................................................... 165Advantages and Disadvantages of Framesets .................................................................................................................... 166Manipulating the Frameset .................................................................................................................... 174Finding Your Way Round the Frameset............................................................................................................................... 174Using Hyperlinks with Frames ................................................................................................................ 177

    Layers .................................................................................................................185

    Summary .............................................................................................................190

    Chapter 6: Behaviors and Dynamic Effects 191

    An Overview of Browser Scripting .........................................................................192Dynamic HTML ..................................................................................................................................... 193Attaching Multiple Behaviors to an Element ....................................................................................................................... 197

    Using Layers to Provide Extra Information .............................................................199

    Swapping Images.................................................................................................204

    Hidden Layers ......................................................................................................208Using Image Maps with Behaviors.......................................................................................................... 212

    Summary .............................................................................................................216

    Chapter 7: User Interaction with ASP and Forms 219

    HTML Forms ........................................................................................................220Form Validation .................................................................................................................................... 234

    Improving Forms with CSS....................................................................................236

    Introduction to Dynamic Content ..........................................................................238

    Dynamic Web Pages ............................................................................................240Active Server Pages (ASP) ..................................................................................................................... 242

    Creating an ASP Page ..........................................................................................244

  • Table of Contents

    iv

    Using Forms with ASP.......................................................................................... 247Conditional Output ................................................................................................................................249Bringing it all Together ...........................................................................................................................251

    Summary ............................................................................................................. 254

    The Soccer Site

    Chapter 8: Adding Logic to Your ASP Pages 257

    Our Sample Site................................................................................................... 258Creating the Basics of Our Site ..............................................................................................................258Creating the Site Structure.....................................................................................................................262

    Passing Values from Page to Page ....................................................................... 273Creating a Form That Uses GET ..............................................................................................................274The Request Object...........................................................................................................................................................275The Response Object ........................................................................................................................................................276

    Sending Values with GET...................................................................................................................................................276

    Retrieving Submitted Values..............................................................................................................................................279Sending and Receiving Values Using POST.........................................................................................................................280

    Post Back .........................................................................................................................................................................281

    Using Information on Multiple Pages .................................................................... 286The Session Object ...............................................................................................................................286Enabling Session State .....................................................................................................................................................287Exploring Session State ....................................................................................................................................................290

    The Global.asa File ...........................................................................................................................................................293

    Saving Values for Use Throughout the Site............................................................ 296The Application Object ...........................................................................................................................296Creating a Hit Counter.......................................................................................................................................................298

    Summary ............................................................................................................. 301

    Chapter 9: Keeping Track of Users 303

    Saving Information about a Page .......................................................................... 304Cookies in Detail...................................................................................................................................305Forewarned is Forearmed.......................................................................................................................310Buffering Output................................................................................................................................................................310

    Changing Code Logic.........................................................................................................................................................311Improving the User's Browsing Experience ..............................................................................................311

    Site Tracking....................................................................................................... 319Grouping Code Together ....................................................................................................................................................319

    Using Include Files............................................................................................................................................................321Page Monitoring ....................................................................................................................................322

    Summary ............................................................................................................. 331

  • Table of Contents

    v

    Chapter 10: Securing Websites 333

    Protecting Pages .................................................................................................334Creating a Login Form ........................................................................................................................... 334Enhancing the Login Form ..................................................................................................................... 341Protecting Our Pages ............................................................................................................................ 353Improving Usability: Using the Referrer ................................................................................................... 357Preparing for Growth ............................................................................................................................. 361The FileSystemObject ....................................................................................................................................................... 362

    Summary .............................................................................................................368

    Chapter 11: Personalizing Websites 369

    Personalizing GlobalSoccerEvents.com .................................................................369Using Color Schemes............................................................................................................................ 369Remembering Our Theme...................................................................................................................... 384Your Own Color Picker........................................................................................................................... 387Changing the Site Badge....................................................................................................................... 395

    Summary .............................................................................................................410

    Chapter 12: Getting Information from a Database 413

    What is a Database?............................................................................................414

    The Sample Database ..........................................................................................417Different Kinds of Databases................................................................................................................. 419Securing a Database ............................................................................................................................ 421Changing Access Permissions........................................................................................................................................... 422

    Creating a Database-Driven Site ...........................................................................427Enhancing Our Login page ..................................................................................................................... 431Fine-Tuning Access to Your Site ............................................................................................................. 439What is an Access Level? ................................................................................................................................................. 439Extending Access-Level Functionality ...................................................................................................... 444

    Summary .............................................................................................................450

    Chapter 13: Displaying Data in Web Pages 453

    Displaying Database-Driven Events .......................................................................453Displaying a List of Events .................................................................................................................... 454Extending the Repeat Region................................................................................................................. 466Filtering Database Values Using a Drop-Down List.............................................................................................................. 466Viewing Details of an Event ................................................................................................................... 474Linking the Event List to the Detail Page............................................................................................................................ 474

    Showing Details of an Event.............................................................................................................................................. 476Adding Error Handling........................................................................................................................................................ 481

  • Table of Contents

    vi

    Paging Data ..........................................................................................................................................485Limiting the Events List .....................................................................................................................................................486

    Navigating the Data...........................................................................................................................................................487Improving Our Navigation System.......................................................................................................................................490

    Summary ............................................................................................................. 493

    Chapter 14: Storing Information in a Database 495

    Maintaining our Events ........................................................................................ 496An Introduction to Using JOINS...............................................................................................................497Viewing Available Events........................................................................................................................499Creating New Events .............................................................................................................................508Adding a Simple Insert Form..............................................................................................................................................510Spicing up the Form ..........................................................................................................................................................520Changing Existing Events .......................................................................................................................528Deleting Events.....................................................................................................................................536

    GlobalSoccerEvents.com...................................................................................... 542

    Summary ............................................................................................................. 544

    MediaEdge and Building Blocks

    Chapter 15: Effective Site Design and Architecture: A Modular System 547

    The MediaEdge Website....................................................................................... 548Overview of the Building Block Technology...............................................................................................549Navigation and Content .....................................................................................................................................................551The Layout........................................................................................................................................................................553

    Creating the MediaEdge Site................................................................................ 555Index.asp .............................................................................................................................................557Setting up the Page Properties of Index.asp.......................................................................................................................558

    Table Layout .....................................................................................................................................................................560

    Adding a Search Field using Flash MX................................................................................................................................563Creating a New Server Behavior.........................................................................................................................................565

    Implementing the New Server Behavior ..............................................................................................................................567Images.................................................................................................................................................571Using Cascading StyleSheets.................................................................................................................571

    Summary ............................................................................................................. 575

  • Table of Contents

    vii

    Chapter 16: Creating the Building Block 577

    The Building Block ...............................................................................................578

    The Building Block Database................................................................................579Creating the Database .......................................................................................................................... 580Creating the Sections Table .............................................................................................................................................. 581Creating the Content Table................................................................................................................................................ 584

    Creating the Section_Content Table................................................................................................................................... 586The Database Connection ..................................................................................................................... 587Using the Database in buildingBlock.asp ................................................................................................ 589Adding a Rollover Image to the Building Block.................................................................................................................... 592

    Creating the Building Block Recordset ............................................................................................................................... 594Creating a Dynamic Image Server Behavior ........................................................................................................................ 596

    Making the Building Block's Images Dynamic..................................................................................................................... 599Inline Frames (iFrames)......................................................................................................................... 603Dynamic Dimensions for the Center Cell ............................................................................................................................ 606Creating Content .................................................................................................................................. 608

    Summary .............................................................................................................613

    Chapter 17: Creating a Content Management System 615

    Updating the Database.........................................................................................616Adding Fields to our Content Table......................................................................................................... 616Creating a Subnavigation Table ......................................................................................................................................... 617

    Overview of a Content Management System .........................................................619Content Creation .................................................................................................................................. 620Record Locking ................................................................................................................................................................. 620Single-Sourcing................................................................................................................................................................. 621

    Metadata Creation............................................................................................................................................................ 623Linking ............................................................................................................................................................................. 623

    Ease of Use...................................................................................................................................................................... 624Content Storage Issues......................................................................................................................... 624Permissions ..................................................................................................................................................................... 625Publishing ............................................................................................................................................ 626Presentation......................................................................................................................................... 627

    Building our CMS .................................................................................................628Creating a User Options Page................................................................................................................ 628Adding the Edit and Delete Buttons ................................................................................................................................... 629Developing a Content Creation Page ...................................................................................................... 633Developing the Content Update Page ..................................................................................................... 638Removing the ID Field ....................................................................................................................................................... 641Developing the Content Deletion Page.................................................................................................... 642Extending the Forms ............................................................................................................................. 644

    Summary .............................................................................................................646

  • Table of Contents

    viii

    Chapter 18: Completing the Building Block Structure 647

    Block Navigation ................................................................................................. 648blockNav.asp in Action ..........................................................................................................................650

    Creating the New Files......................................................................................... 651Session Variables .............................................................................................................................................................656Preventing Page Caching ...................................................................................................................................................658Creating blockMain.asp .........................................................................................................................659Search Capabilities ...............................................................................................................................663

    Adding Content Data ........................................................................................... 668Overview of Adding Content....................................................................................................................668Adding Content to the Sections Table ................................................................................................................................668

    Adding Content to the Content Table..................................................................................................................................674File Associations...............................................................................................................................................................676

    Loading Different Types of Content....................................................................... 680

    Summary ............................................................................................................. 680

    Chapter 19: Going Beyond – Dreamweaver MX Extensions 681

    Dreamweaver Extensions ..................................................................................... 681Installing the Extension Manager............................................................................................................682Using the Extension Manager ............................................................................................................................................684Extension Format ..................................................................................................................................685The Macromedia Exchange for Dreamweaver......................................................................................................................686Comments and Ratings.....................................................................................................................................................687

    Macromedia Approved.......................................................................................................................................................688

    Adding the PayPal Shopping Cart Extension.......................................................... 688

    Summary ............................................................................................................. 698

  • Table of Contents

    ix

    Appendices

    A: Using ASP.NET with Dreamweaver MX 701

    B: PHP and MySQL 715

    C: JavaServer Pages 725

    D: Using ColdFusion MX with Dreamweaver MX 739

    E: Using a Remote Server 753

    Index 761

  • Introduction

    The rise of the Internet over recent years means that, for many of us, websites are now part ofeveryday life. We use them for research, for news, for shipping, for games, for information.There is 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 shear number of websites in existencethese days, it's still possible to create a new website, get it out there on the Internet, and get itnoticed. Of course, it's a good idea to have something interesting to say on your website, butthat's not all – you can make you website more attractive with some suitable page design andappropriate use of features, and you can make it more functional and useful with the help ofsome back-end data storage and data manipulation.

    That sounds great in principle, but how can you do it in practice? If you don't know the basics,then the amount you need to learn about each of the languages (and how they work together)seems daunting. Even if you already know the basics of HTML, JavaScript, ASP, and so on,then it's still useful to be able to use your knowledge to build attractive websites quickly andeffectively, without the hassle of typing in every last line of code.

    For both types of web developer, Macromedia's Dreamweaver MX provides a solution.Dreamweaver MX is a powerful web development tool that will help you to create attractive,dynamic, powerful websites. Its many tools and features not only enable you to create webpages and websites quickly and painlessly, but they also help you to structure your web sites insuch a way that they are easy to maintain after you've built them.

    If you're new to the coding languages of the web, then fear not – Dreamweaver MX will writethe code for you. If you're familiar with the basics, then Dreamweaver can help you to createfeature-rich websites with considerable ease – it will generate the code for you and allow you tochange the code it generates so that you have complete control over the final result.

  • Introduction

    2

    What Does this Book Cover?This book is a practical introduction to Dreamweaver MX. 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 along the way we build three attractive, functional websites.

    We'll also take a look at the code that Dreamweaver generates, and explain how it works. Thisis important – you can achieve a lot just by using the point-and-click features of Dreamweaver,but you can achieve even more if you have an understanding of what is going on behind thescenes. Therefore, in this book, we examine both.

    How is this Book Structured?In this book we create three complete websites. We use a step-by-step approach to building thesites, and explain each step so that you know what is going on. We also provide the completesource code for all three chapters at http://www.wrox.com, so that you have the option ofbuilding as much as you like of each site for yourself, or simply placing the source code on aweb server and watching it work.

    Each website is quite different in nature, and they achieve quite different purposes. You can useeach of the sites as a basis for your own ideas, and hence develop them into sites that you willbe proud to publish. Briefly, the three websites are as follows.

    Section 1 – The Cooking PlaceIn Section 1 (Chapters 1–7) of the book, we create a hobbyist site, called The Cooking Place. Thepurpose of this site is as a resource for all things culinary – cooking techniques, recipes,equipment, news, and so on. As you build this site you'll learn how to use Dreamweaver MX to:

    ❑ Plan, create, and set up a website

    ❑ Add web pages to the site, and edit their content

    ❑ Use stylesheets and templates to create a consistent style across the site

    ❑ Use tables, frames, 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 webpages to capture submitted information and react to it

  • Introduction

    3

    Section 2 – The Soccer SiteAs we progress through the book, the sites become increasingly ambitious. In Section 2(Chapters 8–14) you'll build a soccer fan site, that provides information on upcoming events forsoccer fans around the world. As you build this site, you'll see how to use Dreamweaver MX to:

    ❑ Add logic to your ASP pages, so that you can display different information to differentusers (depending on their location, or even on the time of day)

    ❑ Keep track of users as they move around the site, so that you can find out what partsof your site are the most popular

    ❑ Secure parts of the website so that only authorized users are allowed to seesensitive information

    ❑ Personalize the website for individual users, so that the site appears in the colors ofthe user's favorite team or so that they see only events occurring in their home country

    ❑ Store and extract information about users and upcoming events in a database, and usethis information to create web pages dynamically

    Section 3 – MediaEdge and Building BlocksIn Section 3 (Chapters 15–19), we build a site that shows off many of the advanced features ofDreamweaver MX. As you progress through these chapters, you'll see how to design a modular,extensible, and scalable website, and create a set of dynamic building blocks that can be quicklymodified and reused in different sites.

    As you build this site (which is used to display a set of images that users can view andpurchase) you'll learn how to use Dreamweaver MX to:

    ❑ Create a set of building blocks whose look and content is determined dynamically bythe settings in a database

    ❑ Create a content management page that you can use to mange the database that storesinformation about the images on the site, including their title, price, and how theyshould be laid out

    ❑ Put the building blocks you created earlier to a variety of uses, including a newsblogger, a media display, and a product display

    ❑ Use Dreamweaver Extensions to make our building blocks easy to reuse and to add e-commerce functionality to the site

  • Introduction

    4

    The AppendicesAs you work through the book you'll learn enough about languages such as HTML, JavaScript,and CSS to have a good understanding of what Dreamweaver does for you behind the scenes –this is knowledge that will help you to create better, more effective websites.

    You'll also learn about server-side web programming using Active Server Pages (ASP). This isa valuable skill in itself, but this will also prove useful if you eventually plan to build websiteswith JavaServer Pages (JSP), ASP.NET, PHP, or ColdFusion MX. Dreamweaver MX supports allof these server-side programming technologies – indeed, programming in any of theselanguages is very similar in Dreamweaver MX, and the core concepts you learn in building websites with ASP are applicable and easily transferred to other languages. To help, this bookincludes four appendices that provide fast paced guides on how to get started using JSP,ASP.NET, PHP, and ColdFusion MX with Dreamweaver MX.

    Why Not Try…Each chapter includes a Why Not Try…? section. In these sections, we suggest tasks andexercises that you might do using the concepts and techniques covered in that chapter. They'redesigned to help you reinforce the ideas for yourself, or to extend them – and to encourage youto experiment with new features of Dreamweaver MX and website development in general.

    Some of the suggestions come with hints for how you should set about the task – but moredetailed guides for each can be found at http://p2p.wrox.com/exercises/.

    Who is this Book For?This book has two primary audiences. If you are new to the world of web development, andyou have access to Dreamweaver MX (or you're thinking of buying Dreamweaver MX) thenyou can use this book to learn about website development using Dreamweaver MX. We'll showyou what to do, and you'll learn enough about the important topics and about what happensbehind the scenes to start creating attractive, functional websites very quickly.

    If you've already done some website programming in the past, but you're new to Dreamweaver(or just new to the latest version of Dreamweaver), then this book will show you how to achievethe tasks you've been working on, but in far less time and with far fewer bugs! Dreamweavergenerates as much code as you want it to, and it's a great tool for rapid applicationdevelopment and proof-of-concept development.

  • Introduction

    5

    What You Need for this BookTo build and run the websites in this book you'll need:

    ❑ Windows 2000 Professional, Server, or Advanced Server edition;or Windows XP Professional Edition.

    ❑ Internet Information Services (IIS) 5.0 or 5.1. (IIS is bundled with the operatingsystems listed above, but not with Windows XP Home edition.) IIS comes completewith the facilities necessary to run server-side ASP coding.

    ❑ Macromedia's Dreamweaver MX.

    If you don't already have a copy of Dreamweaver MX, you can download a 30-day evaluationedition from Macromedia at http://www.macromedia.com/software/trial_download/. The evaluationedition is full-featured, and you'll be able to use it to work through all the examples in the book.

    If you have Windows XP Home Edition or Mac OS you will need access to a remote server inorder to run the ASP websites in the book. Appendix E and the Dreamweaver MX 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 betweenthe various styles of information. Here are examples of the styles we use along withexplanations of what they mean:

    Try It Out Conventions

    The Try It Out is an exercise you should work through, following the text in the book.

    1. They usually consist of a set of steps.

    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 Works

    After each Try It Out, the code you've typed in will be explained in detail.

    Background information will look like this.

  • Introduction

    6

    Not-to-be missed information looks like this.

    Bulleted information is shown like this:

    ❑ Important words have a special font.

    ❑ Words that appear on the screen (such as menu options) are in a similar font to the oneused on the screen, for example the File menu.

    ❑ Keys that you press on the keyboard, like Ctrl and Enter, are in italics.

    ❑ All file names are in this style: IceCream.mdb.

    ❑ Any code fragments within normal text are highlighted in a special font.

    Code shown for the first time, or other relevant code, is in the following format:

    Dim intVariable As Integer

    intVariable = 10Debug.Print intVariable

    ...while less important code, or code that you have seen before, looks like this:

    intVariable = 10

    Customer SupportWe always value hearing from our readers, and we want to know what you think about thisbook: what you liked, what you didn't like, and what you think we can do better next time. Youcan send us your comments, either by returning the reply card in the back of the book, or by e-mail to [email protected]. Please mention the book's title and the last four digits of the ISBN(8201) in your message.

    ErrataWe've made every effort to make sure that there are no errors in the text or in the code.However, no one is perfect and mistakes do occur. If you find an error in one of our books, likea spelling mistake or a faulty piece of code, we would be very grateful for feedback. By sendingin errata you may save another reader hours of frustration and, of course, you will be helpingus provide even higher quality information. Simply e-mail the information [email protected]. Your information will be checked and, if correct, posted to the errata pagefor that title, or used in subsequent editions of the book.

  • Introduction

    7

    To find errata on the Web, go to http://www.wrox.com/ and locate the title through our Find aBook search engine or our book list. Then click on the book's View errata link.

    E-mail SupportIf you wish to directly query a problem in the book with an expert who knows the book indetail then e-mail [email protected], with the title of the book and the last four numbers ofthe ISBN in the subject field of the e-mail. A typical e-mail should include the following things:

    ❑ The title of the book, last four digits of the ISBN, and page number of the problem inthe Subject field. For example, 'Beginning Dreamweaver MX, 8201, Page 42'.

    ❑ Your name, contact information, and the problem in the body of the message.

    We won't send you junk mail. We need the details to save your time and ours. When you sendan e-mail message, it will go through the following chain of support:

    ❑ Customer Support – Your message is delivered to our customer support staff, who arethe first people to read it. They have files on most frequently asked questions and willanswer anything general about the book or the website immediately.

    ❑ Editorial – Deeper queries are forwarded to the technical editor responsible for thatbook. They have experience with the programming language or particular product,and are able to answer detailed technical questions on the subject.

    ❑ The authors – Finally, in the unlikely event that the editor cannot answer yourproblem, they will forward the request to the author. We do try to protect the authorfrom any distractions to their writing; however, we are quite happy to forward specificrequests to them. All Wrox authors help with the support on their books. They will e-mail the editor with their response and, again, all readers should benefit.

    The Wrox Support process can only offer support to issues that are directly pertinent to thecontent of the published title. Support for questions that fall outside the scope of normal booksupport is provided via the community lists of our http://p2p.wrox.com/ forum.

    p2p.wrox.comFor author and peer discussion, join the P2P mailing lists. Our unique system providesprogrammer to programmer™ contact on mailing lists, forums, and newsgroups, all in additionto our one-to-one e-mail support system. If you post a query to P2P, you can be confident that itis being examined by the many Wrox authors and other industry experts who are present onour mailing lists. At p2p.wrox.com you will find a number of different lists that will help you,not only while you read this book, but also as you develop your own applications. Particularlyappropriate to this book are the lists under the Web Design category (p2p.wrox.com/webdesign/).

  • Introduction

    8

    To subscribe to a mailing list just follow these steps:

    1. Go to http://p2p.wrox.com/.

    2. Choose the appropriate category from the left menu bar.

    3. Click on the mailing list you wish to join.

    4. Follow the instructions to subscribe and fill in your e-mail address and password.

    5. Reply to the confirmation e-mail you receive.

    6. Use the subscription manager to join more lists and set your e-mail preferences.

    Why this System Offers the Best SupportYou can choose to join the mailing lists or you can receive them as a weekly digest. If you don'thave the time, or facility, to receive the digest, then you can search our online archives. Junkand spam mails are deleted, and your own e-mail address is protected by the unique Lyrissystem. Queries about joining or leaving lists, and any other general queries about lists, shouldbe sent to [email protected].

  • Introduction

    9

  • The Cooking Place

    Chapter 1: Getting Started with Dreamweaver MX 11

    Chapter 2: Creating a Website 43

    Chapter 3: Site Structure, Navigation, and Content 83

    Chapter 4: Stylesheets and Templates 121

    Chapter 5: Using Layers and Frames for Layout 163

    Chapter 6: Behaviors and Dynamic Effects 191

    Chapter 7: User Interaction with ASP and Forms 219

    1

  • Getting Started withDreamweaver MX

    Over the past twenty years the Internet has evolved tremendously, from an obscure networkingtool used by select academic and government institutions to a means of connecting millions ofpeople worldwide.

    Yet the Internet is still, in its most basic form, a wide area network. This means that it is a seriesof interconnected nodes that can connect computers together over a large (or even global)geographic area. Today, at any given moment, the number of people using this wide areanetwork is estimated to be between 600 million and 1 billion; and this number continues togrow. It is just as important to people who use it simply to say "Hello" to a friend many milesaway, as it is to major international corporations who use it to connect offices worldwide.

    With the growth in usage and sophistication of the Internet, there has been a correspondingevolution of technological capabilities. With this evolution, new programming technologieshave emerged. At one time, we constructed our web pages simply using a "formatting"language called HTML. Now, while HTML is just as important as it always was, we also use ahost of other technologies (such as scripting languages, ASP, ColdFusion, XML, and so on) tomeet these new levels of sophistication.

    The great thing is that you don't need to know every last detail about all these technologies tostart building attractive, functional websites. There are a number of development environmentsaround that will help you to do the job. Macromedia's contribution to this arena is itsDreamweaver development environment. The most recent version, Dreamweaver MX, isintegrated with other products in Macromedia's MX suite: Flash MX, Fireworks MX, and so on.

  • Chapter 1

    12

    What's great about Dreamweaver MX? If you want, you can use it to do the bulk of the codingwork for you – that's great when you're not too familiar with the underlying technologies, orwhen you're trying to get the job done quickly. Moreover, as you become better acquaintedwith Dreamweaver, with HTML, and with other related technologies, you'll see thatDreamweaver also allows you to tinker with the code itself – or simply to look at the code andget a better understanding of what you're creating.

    As exciting as all this sounds, we must start at the beginning. Before we can do anything wemust set up a few things. So, in this chapter we will:

    ❑ Take a quick look at how the Internet works, and how Dreamweaver (and other toolsfrom Macromedia) play their part in the creation of websites

    ❑ Install the tools you will need as you work through this book – the Dreamweaver MXweb development tool, and the Microsoft IIS web server

    ❑ Set up the Dreamweaver workspace to suit your own personal needs

    Over the course of the first eight chapters of this book, we'll build a website on a subject closeto my heart – food and cookery. While we indulge my passion for fine cuisine, we'll also gainsome familiarity with the Dreamweaver development tool, and begin to learn about the art ofweb development with Dreamweaver MX.

    As we progress through the book, we'll also learn a lot about HTML, scripting languages, andASP, and we'll see how to use Dreamweaver MX to help us create great websites using theseimportant technologies.

    A Brief Overview of the InternetI'm sure you're familiar with using the Internet. You open a browser; you type in the address ofa website (or click on a button or a link); and then you wait a while. Then, after a short time, apage appears in the browser. It's simple.

    But before you can request that web page, somebody somewhere has to take the trouble tocreate the web page and publish it. (They may even have used Dreamweaver MX to do that.)

    In this section, we'll look at this simple process, and get an understanding of how the pagerequest is processed, because it's at the root of everything else we do in this book.

    Static Web Pages and Dynamic Web PagesWhen it was first born (and for a while even after it started to become more widely used), all ofthe web pages published on the Internet were static web pages. A static web page, essentially,is a web page that is created, in its entirety, at some time before any user visits the page.