Tải bản đầy đủ (.pdf) (849 trang)

mastering web development with microsoft visual studio 2005 (2005)

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (24.47 MB, 849 trang )


Mastering

Web Development with
Microsoft Visual Studio 2005

4439.book.fm Page i Wednesday, October 19, 2005 12:23 AM

4439.book.fm Page ii Wednesday, October 19, 2005 12:23 AM

Wiley Publishing, Inc.

Mastering





Web Development with
Microsoft

®

Visual Studio

®

2005

John Paul Mueller



4439.book.fm Page iii Wednesday, October 19, 2005 12:23 AM

Acquisitions and Development Editor: Tom Cirtin
Technical Editor: Russ Mullen
Production Editor: Rachel Gunn
Copy Editor: Cheryl Hauser
Production Manager: Tim Tate
Vice President & Executive Group Publisher: Richard Swadley
Vice President and Executive Publisher: Joseph B. Wikert
Vice President and Publisher: Neil Edde
Book Designer: Maureen Forys, Happenstance Type-O-Rama; Judy Fung
Compositor: Chris Gillespie, Happenstance Type-O-Rama
Proofreader: Nancy Riddiough
Indexer: Nancy Guenther
Cover Design: Design Site
Copyright

©

2005 by Wiley Publishing, Inc., Indianapolis, IN
Published by Wiley Publishing, Inc., Indianapolis, IN
Published simultaneously in Canada
ISBN-13: 978-0-7821-4439-X
ISBN-10: 0-7821-4439-X
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic,
mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States
Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-
copy fee to the Copyright Clearance Center, 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-4355, or online at />Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy
or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for
a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained
herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal,
accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be
sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Website is
referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses
the information the organization or Website may provide or recommendations it may make. Further, readers should be aware that Internet
Websites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services or to obtain technical support, please contact our Customer 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 be available in electronic books.
TRADEMARKS: Sybex, Wiley, Mastering and related trade dress are trademarks of Wiley Publishing, Inc. or its parent company, in the
United States and other countries, and may not be used without written permission. All other trademarks are the property of their
respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book.
Screen reproductions produced with FullShot 99. FullShot 99 © 1991-1999 Inbit Incorporated. All rights reserved.
FullShot is a trademark of Inbit Incorporated.
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1

4439.book.fm Page iv Wednesday, October 19, 2005 12:23 AM

This book is dedicated to my brother Mark on his 41st birthday;
may all your wishes come true.

4439.book.fm Page v Wednesday, October 19, 2005 12:23 AM

Acknowledgments

Thanks to my wife, Rebecca, for working with me to get this book completed. I really don’t know

what I would have done without her help in researching and compiling some of the information that
appears in this book. She also did a fine job of proofreading my rough draft and page proofing the
result. Rebecca also helps a great deal with the glossary and keeps the house running while I’m buried
in work.
Russ Mullen deserves thanks for his technical edit of this book. He greatly added to the accuracy
and depth of the material you see here. Russ is always providing me with great URLs for new prod-
ucts and ideas. However, it’s the testing that Russ does that helps most. He’s the sanity check for my
work and my code.
A number of people read all or part of this book to help me refine the approach, test the coding
examples, and generally provide input that every reader wishes they could have. These unpaid vol-
unteers helped in ways too numerous to mention here. I especially appreciate the efforts of Eva Beat-
tie, who read the entire book and selflessly devoted herself to this project. Bill Salkin provided me
with a great many ideas and URLs, as well as tested some of the examples for me. A number of other
readers tested procedures and helped refine the book in other ways.
Finally, I would like to thank Tom Cirtin, Mae Lum, Rachel Gunn, Cheryl Hauser, and the rest
of the editorial and production staff at Sybex for their assistance in bringing this book to print. It’s
always nice to work with such a great group of professionals and I very much appreciate the friend-
ship we’ve built over the last five books.

4439.book.fm Page vi Wednesday, October 19, 2005 12:23 AM

About the Author

John Mueller is a freelance author and technical editor. He has writing in his blood, having produced
68 books and over 300 articles to date. The topics range from networking to artificial intelligence and
from database management to heads down programming. Some of his current books include a
Windows power optimization book, a book on .NET security, and books on Amazon Web Services,
Google Web Services, and eBay Web Services. His technical editing skills have helped over 39 authors
refine the content of their manuscripts. John has provided technical editing services to both


Data Based
Advisor

and

Coast Compute

magazines. He’s also contributed articles to magazines like

DevSource

,

InformIT

,

SQL Server Professional

,

Visual C++ Developer

,

Hard Core Visual Basic

,

asp.netPRO


,

Software
Test and Performance

, and

Visual Basic Developer

. He’s currently the editor of the .NET electronic news-
letter for Pinnacle Publishing (

/>
).
When John isn’t working at the computer, you can find him in his workshop. He’s an avid wood-
worker and candle maker. On any given afternoon, you can find him working at a lathe or putting the
finishing touches on a bookcase. He also likes making glycerin soap and candles, which comes in
handy for gift baskets. You can reach John on the Internet at



. John is also setting
up a Web site at:

/>
; feel free to look and make suggestions on how
he can improve it. One of his current projects is creating book FAQ sheets that should help you find
the book information you need much faster.


4439.book.fm Page vii Wednesday, October 19, 2005 12:23 AM

Contents at a Glance

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

Part 1 • Discovering Visual Web Developer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Chapter 1 • Working with Visual Web Developer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Chapter 2 • Creating a Simple Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Chapter 3 • Using Server Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Part 2 • Using Built-in Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

Chapter 4 • Working with ASP.NET 2.0 Master Pages and Themes . . . . . . . . . . . . . . . . . 83
Chapter 5 • Building Intelligent Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Chapter 6 • Working with Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

Part 3 • Creating Simple but Effective Pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

Chapter 7 • Creating Feedback Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Chapter 8 • Developing a Site Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Chapter 9 • Using Pop-ups and Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

Part 4 • Working with Dynamic Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

Chapter 10 • Developing Simple Database Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Chapter 11 • Using SQL Server 2005 Efficiently . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Chapter 12 • Creating an ASP.NET Crystal Reports Web Site . . . . . . . . . . . . . . . . . . . . . 359
Chapter 13 • Developing Multi-tier Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381


4439.book.fm Page viii Wednesday, October 19, 2005 12:23 AM

CONTENTS AT A GLANCE

ix

Part 5 • Developing Full-blown Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . 403

Chapter 14 • Designing Dynamic Pages with Pizzazz . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Chapter 15 • Working with Client-side Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
Chapter 16 • Creating a Shopping Cart Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481

Part 6 • The Finishing Touches: Debug, Secure, and
Distribute Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523

Chapter 17 • Debugging Your Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
Chapter 18 • Designing Secure Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
Chapter 19 • Optimizing Your Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
Chapter 20 • Creating Downloadable Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 597
Chapter 21 • Creating Accessible Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629

Part 7 • Application Development Within the Corporate Environment . . . . . . . 661

Chapter 22 • Developing Interoperable Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663
Chapter 23 • Using the Team Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 679
Chapter 24 • Converting Visual Studio 2003 Applications . . . . . . . . . . . . . . . . . . . . . . . . 701
Chapter 25 • Moving to Visual Studio 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717

Appendices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735


Appendix A • A Guide to Common Development Errors . . . . . . . . . . . . . . . . . . . . . . . . . 733
Appendix B • Working with Common Character Codes . . . . . . . . . . . . . . . . . . . . . . . . . . 745
Appendix C • 52 Indispensable Visual Studio Tricks and Techniques. . . . . . . . . . . . . . . 753

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 759
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789

4439.book.fm Page ix Wednesday, October 19, 2005 12:23 AM

Contents

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

Part 1 • Discovering Visual Web Developer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 1 • Working with Visual Web Developer . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Introducing Visual Web Developer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Understanding What Visual Web Developer Provides . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Understanding How Visual Web Developer Differs from Visual Web
Developer Express Edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Understanding the ASP.NET 2.0 Difference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Performing the Visual Web Developer Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Using the IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
An Overview of the IDE Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Modifying the Visual Web Developer Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Using the Design View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Using Source View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Using the Code View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Working with the Personal Web Site Starter Kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Creating the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Working with the Application Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Modifying the Application Template to Meet Specific Needs . . . . . . . . . . . . . . . . . . . . 23
Defining the Enterprise Web Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Chapter 2 • Creating a Simple Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Using the Built-in Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Advantages of Using the Built-in Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Disadvantages of Using the Built-in Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Creating the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Using the Build Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Using the Standard Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Finding and Replacing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Working with the Browser Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Understanding Save/Refresh Style Page Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Performing Tasks One at a Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Using the Task List Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Using the HTML Source Edit Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Working with Control SmartTags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Using Internet Information Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Working with Local IIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Creating New Projects with IIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Using the Copy Web Site Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

4439.book.fm Page x Wednesday, October 19, 2005 12:23 AM

CONTENTS


xi

Designing Your Application Using Visio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Deciding What to Create . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Designing a Site Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Working with Existing Web Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

Chapter 3 • Using Server Explorer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Understanding Server Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Creating a Server Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
An Overview of Data Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
An Overview of Crystal Reports Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
An Overview of Message Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
An Overview of Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Working with Event Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Using Standard Event Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Developing Custom Event Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Working with Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Viewing Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Creating a Simple Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

Part 2 • Using Built-in Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Chapter 4 • Working with ASP.NET 2.0 Master Pages and Themes . . . . . . . . . . . . 83

Understanding Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Designing Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Creating the Master Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

Using Existing Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Defining the Master Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Creating a Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Using the Layout Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Creating a Project with Master Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Creating a Content Page Using a Master Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Adding a Master Page to an Existing Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Using Multiple Master Pages in a Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Understanding Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Designing Your Own Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Creating a Themes Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Defining a CSS File for a Theme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Defining the SKIN File and Adding Theme Resources . . . . . . . . . . . . . . . . . . . . . . . . . 102
Creating a Simple Project Using Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Applying a Theme to a Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Applying a Theme to a Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Working with Cascading Style Sheets (CSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Using the Style Sheet Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Designing Flexible Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

4439.book.fm Page xi Wednesday, October 19, 2005 12:23 AM

xii

CONTENTS



Creating and Using a CSS File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Working with CSS in the Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

Working with Microsoft Using the Web Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

Chapter 5 • Building Intelligent Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

Understanding Server-side Intelligence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Detecting the Client Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Working with Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Deciding between the GET and POST Data Handling Methods . . . . . . . . . . . . . . . . . 124
Understanding the Four Levels of Data Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Processing Input Using the GET Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
Processing Input Using the POST Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Understanding the New ASP.NET 2.0 Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Using XML Instead of HTML for Web Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Creating the XML Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Interpreting the XML Using XSLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Learning More about XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Learning More about XSLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Developing a Privacy Policy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Creating a Safe Environment for User Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

Chapter 6 • Working with Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

Understanding Client-side Intelligence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Using Basic Scripting Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Creating Efficient and Effective Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Debugging Your Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Learning More about JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Working with Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

Working with HTML Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Using the

<Object>

Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Relying on ASP.NET Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Scripting with Client Callback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Storing and Deleting Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Creating and Reading Temporary Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Creating and Reading Permanent Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Using WebParts to Automate User Customizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Adding the

WebPartManager

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Changing Selections Using a Custom Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Creating Content with the WebPartZone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Modifying the Content with an

EditorZone

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Adding New Items with the

CatalogZone

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Viewing the Script behind the Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

Keeping Data Safe with Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

4439.book.fm Page xii Wednesday, October 19, 2005 12:23 AM

CONTENTS

xiii

Part 3 • Creating Simple but Effective Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Chapter 7 • Creating Feedback Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

Understanding the Need for Feedback Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Targeting Feedback Forms to Meet Specific Needs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Considering What You Expect from the Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Defining the Basic User Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Using a Master Page to Create Multiple Feedback Form Types . . . . . . . . . . . . . . . . . . 197
Creating a User Satisfaction Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Designing User Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Developing Automated Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Creating a Help Request Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Designing the Request Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Developing the XML Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Transforming the Results with XSLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
Developing a Beneficial Suggestion Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Deciding between Required and Optional Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Devising Methods of Reducing Repeat Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

Chapter 8 • Developing a Site Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219


Understanding the Site Search Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Creating a Custom Site Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Developing a Simple Site Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Defining Preferred Links Based on Site Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Using Google to Create a Site Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Using the Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
Performing a Simple SOAP Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Using a Script to Call an XSLT Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Translating the Result with XSLT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Discovering Site Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Understanding the Differences between a Site Map and a Site Search . . . . . . . . . . . . 250
Using the Site Navigation Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
Creating a Site Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254

Chapter 9 • Using Pop-ups and Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255

Understanding User Concerns over Pop-ups and Redirection . . . . . . . . . . . . . . . . . . . . . 256
Creating a Pop-up Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Using Pop-up Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Additional Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Help Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
User Survey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Using Meta Refresh for Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275

4439.book.fm Page xiii Wednesday, October 19, 2005 12:23 AM

xiv


CONTENTS



Employing Server-side Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Understanding How Server-side Redirection Works . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Using the Coded Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Modifying the

<customErrors>

Element of the

WEB.CONFIG

File . . . . . . . . . . . . . . . . 280
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281

Part 4 • Working with Dynamic Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Chapter 10 • Developing Simple Database Applications . . . . . . . . . . . . . . . . . . . . 285

Understanding the New SQL Server 2005 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Working with SQL Server 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
Working with SQL Computer Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
Using the SQL Server Management Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Using the SQLCmd Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Creating a Database Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Creating a Connection to SQL Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Creating a Connection to Other DBMSs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
Creating a Connection to Microsoft Access Using ODBC . . . . . . . . . . . . . . . . . . . . . . . 307

Designing a Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
Developing a SQL Server Database Using the Wizard . . . . . . . . . . . . . . . . . . . . . . . . . 311
Obtaining the Northwind and Pubs Sample Databases . . . . . . . . . . . . . . . . . . . . . . . . 311
Relying on Code-free Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314

Chapter 11 • Using SQL Server 2005 Efficiently . . . . . . . . . . . . . . . . . . . . . . . . . . . 315

Accessing the Database from Visual Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Using the Server Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316
Creating Database Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Using the Table Designer Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323
Using the Data Design Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Using the Query Designer Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
Creating a Blank Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Adding the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Designing the Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Assigning the Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Creating and Accessing Stored Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Working with Stored Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Modifying Stored Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Creating New Stored Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Developing Stored Procedures with .NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Learning More about Stored Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Using Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Using the View Designer Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Creating a View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354

4439.book.fm Page xiv Wednesday, October 19, 2005 12:23 AM


CONTENTS

xv

Using XML Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Creating an XML Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Using the XML Data Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Using the XML Schema Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Defining an XML Schema . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Using the XML Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357

Chapter 12 • Creating an ASP.NET Crystal Reports Web Site . . . . . . . . . . . . . . . . 359

Creating the RPT File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Adding the Crystal Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Selecting the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Choosing the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
Working with Field Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
Formatting Report Entries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
Setting the Report Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373
Inserting and Removing Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Inserting and Removing Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
Developing the Output Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Using the

CrystalReportSource

Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Using the


CrystalReportViewer

Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379

Chapter 13 • Developing Multi-tier Applications. . . . . . . . . . . . . . . . . . . . . . . . . . 381

Binding with Middle Tier Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
Understanding the Middle Tier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
Creating Direct Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383
Developing Web Service Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
Working with Multiple Device Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Understanding WAP/WML, XHTML Mobile, and cHTML . . . . . . . . . . . . . . . . . . . . 398
Using the

ContentPager

Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
Working with Emulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402

Part 5 • Developing Full-blown Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Chapter 14 • Designing Dynamic Pages with Pizzazz . . . . . . . . . . . . . . . . . . . . . . 405

Combining Themes, Scripts, and Other Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
Avoiding Pizzazz Overkill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
Using Layout, Themes, and Code Behind Effectively . . . . . . . . . . . . . . . . . . . . . . . . . . 407
Creating Special Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Mouseover with Internet Explorer and Older Browsers . . . . . . . . . . . . . . . . . . . . . . . . 412

Mouseover with Newer Browsers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
Selection Using Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
Progressive Input Using Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422

4439.book.fm Page xv Wednesday, October 19, 2005 12:23 AM

xvi

CONTENTS



Selection and Progressive Input with ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424
Understanding the Ever Changing Browser Playing Field . . . . . . . . . . . . . . . . . . . . . . 425
Creating a Dynamic Presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
Using the Substitution Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
Using the

AdRotator

Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429
Working with WebParts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
Dressing Up the WebParts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
Using the

BehaviorEditorPart

Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Using the


DeclarativeCatalogPart

and

ImportCatalogPart

Controls . . . . . . . . . . . . . . . . 435
Understanding How Much Customization to Provide . . . . . . . . . . . . . . . . . . . . . . . . . 436
Working with Media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
Media Uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
Animated GIFs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439
Audio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442
Interactive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447

Chapter 15 • Working with Client-side Controls . . . . . . . . . . . . . . . . . . . . . . . . . . 449

Understanding User Concerns about Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
Creating a Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Understanding the Difference between Controls and Components . . . . . . . . . . . . . . 451
Designing a Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451
Designing a Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455
Deploying a Component or Control to the Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Working with the ActiveX Control Test Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
Creating the

<Object>


Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
Working with the Microsoft Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465
Signing the MSI File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Registering the Component or Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Setting .NET Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
Considering the Security Issues of Using Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Using the MakeCert Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475
Using the Certification Authority Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478

Chapter 16 • Creating a Shopping Cart Application. . . . . . . . . . . . . . . . . . . . . . . . 481

Understanding the Alternatives to a Custom Application . . . . . . . . . . . . . . . . . . . . . . . . . 481
Alternative Uses of Shopping Cart Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Sidestepping the Pitfalls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Getting a Complete Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Obtaining Application Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
Developing a Merchandizing Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484
Creating a Web Site Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485
Presenting the Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485

4439.book.fm Page xvi Wednesday, October 19, 2005 12:23 AM

CONTENTS

xvii

Developing the Product Data Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
Tracking User Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
Getting the Payment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487

Creating the Required Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
Product Listing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
Customers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
Orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
Defining Table Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
Designing Appropriate Management Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
Choosing Management Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
Displaying the Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495
Changing Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497
Changing Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 498
Creating New Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 500
Updating Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504
Deleting Records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
Creating the Front End Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
Viewing a List of Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
Displaying Product Specifics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 512
Logging the User into the System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514
Displaying the Shopping Basket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
Making the Sale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522

Part 6 • The Finishing Touches: Debug, Secure, and Distribute Your Application . . . . . . 523
Chapter 17 • Debugging Your Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525

Understanding Why Debugging Is Important . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
Considering Syntax Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 526
Considering Compile Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
Considering Runtime Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
Considering Semantic Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Using the Error Lookup Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531

Locating Hidden Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532
Using the Visual Web Developer 2005 Debugging Features . . . . . . . . . . . . . . . . . . . . . . . 534
Using the Debug Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Using the Immediate Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
Using the Command Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
Using the Output Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
Using the Error List Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
Using the Locals Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
Using the Watch Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
Using the Call Stack Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
Managing Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544

4439.book.fm Page xvii Wednesday, October 19, 2005 12:23 AM

xviii

CONTENTS



Chapter 18 • Designing Secure Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545

Understanding the Common Security Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545
Considering the Security Issues That .NET Resolves . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
Determining Where .NET Can’t Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Creating a Security Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Configuring ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Working with the Configuration Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Using the Login Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559

Checking All Incoming Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
An Overview of the Validators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
Using Validators in an Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Hardening Your Applications against Outside Intrusion . . . . . . . . . . . . . . . . . . . . . . . . . . 576
Preventing Data Leaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576
Encrypting Your Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577

Chapter 19 • Optimizing Your Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579

Working with Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
Understanding Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
Using Standard Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Using .NET Specific Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Creating Custom Performance Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
Defining the Custom Performance Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
Creating an

IAsyncResult

Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589
Adding the Performance Counter to Your Application . . . . . . . . . . . . . . . . . . . . . . . . 591
Testing Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
Avoiding Performance Counter Woes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 592
Analyzing Your Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
Using Code Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 593
Using the Performance Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595

Chapter 20 • Creating Downloadable Applications . . . . . . . . . . . . . . . . . . . . . . . . 597


Considering Potential Security Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 598
Considering Client-side Setup and Configuration Issues . . . . . . . . . . . . . . . . . . . . . . . . . . 599
Using the Class Diagram (CD) File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 601
Creating Standard Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Designing the Component . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Adding the Component to a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605
Creating Standard Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
Designing the Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607
Adding the Control to a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
Using the

FileUpload

Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616
Designing Custom SmartTags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618
Adding Standard SmartTags to a Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 619
Getting Pre-built SmartTags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625
Developing Downloadable Application Alternatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627

4439.book.fm Page xviii Wednesday, October 19, 2005 12:23 AM

CONTENTS

xix

Chapter 21 • Creating Accessible Pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629

Reasons to Design with Accessibility in Mind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629

Making Controls Accessible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 631
Adding Accessibility Attributes to Standard Controls . . . . . . . . . . . . . . . . . . . . . . . . . 632
Using Alternative Attributes to Improve Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . 634
Using Alternative Tags to Improve Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635
Organizing the Web Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
Working with Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
Working with Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639
Working with Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
Using the

<NoScript>

Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
Testing Your Page for Accessibility Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652
Using the Visual Studio Built-in Checks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654
W3C HTML Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656
Using Bobby to Test Accessibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659

Part 7 • Application Development Within the Corporate Environment . . . . . . . . . . . . . . 661
Chapter 22 • Developing Interoperable Applications . . . . . . . . . . . . . . . . . . . . . . 663

Understanding the .NET/Java Development Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663
An Overview of the Corporate Mixed Language Environment . . . . . . . . . . . . . . . . . . 664
Developing Reliable Mixed Language Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664
Using the Web Services Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666
Using the Bridging Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
An Overview of JNBridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
Installing JNBridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670
Creating a Bridged Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 670

Using the Cross-Compiler Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
An Overview of Visual MainWin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
Installing Visual MainWin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
Adding IBM WebSphere Support to Visual Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . 674
Creating the Cross-Compiled Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677

Chapter 23 • Using the Team Development Tools . . . . . . . . . . . . . . . . . . . . . . . . . 679

Understanding the Visual Studio 2005 Team Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
Working with Visual SourceSafe (VSS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682
Administering VSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 682
Adding VSS to a Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 688
Working with VSS Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 690
Using Visual SourceSafe Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695
Working with Distributed System Designers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696
Using the Application Connection Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 696
Using the Logical Datacenter Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698
Using the System Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700

4439.book.fm Page xix Wednesday, October 19, 2005 12:23 AM

xx

CONTENTS



Chapter 24 • Converting Visual Studio 2003 Applications . . . . . . . . . . . . . . . . . . 701


Understanding the Process Is One Way . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 701
Deciding Whether You Want to Make a Change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 702
Performing the Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 703
Understanding the Conversion Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704
Overcoming Potential Conversion Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
Considering Deprecated Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 707
Considering Difficult Conversion Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709
Testing the Converted Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709
Exporting Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 710
Creating a Project Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711
Creating an Item Template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 716

Chapter 25 • Moving to Visual Studio 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717

Preserving Your Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 717
Moving the Code to IIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718
Creating a Solution File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 721
Fixing FrontPage Server Extension Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 722
Testing Code in the New Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
Compiling Your Code Using

ASPNet_Compiler.EXE

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 724
Fixing File Association Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725
Using the ASPNet_RegIIS Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726
Using the ASPNet_RegSQL Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
Defining Your Development Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733


Appendices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735

Appendix A • A Guide to Common Development Errors . . . . . . . . . . . . . . . . . . . . 733

Plan before You Write Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
Avoid Performance Bottlenecks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
Use

Page.IsPostBack

to Control Resource Use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
Perform Client-side Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 736
Save the View State Only When Needed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737
Set the Session State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738
Use Pure HTML Whenever Possible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Keep Your Data Safe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
Checking Every Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 740
Verifying Every Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
Work Smarter, Not Harder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
Try the

HttpServerUtility.Transfer

Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
Use Exceptions Carefully . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742

4439.book.fm Page xx Wednesday, October 19, 2005 12:23 AM

CONTENTS


xxi

Use All Available Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 742
Rely on SQL Server Stored Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743
Precompile the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743

Appendix B • Working with Common Character Codes . . . . . . . . . . . . . . . . . . . . 745

Direct Replacement Using a Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745
Using Direct JavaScript Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749
Using Indirect JavaScript Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 749

Appendix C • 52 Indispensable Visual Studio Tricks and Techniques . . . . . . . . . 753

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 759
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 789

4439.book.fm Page xxi Wednesday, October 19, 2005 12:23 AM

4439.book.fm Page xxii Wednesday, October 19, 2005 12:23 AM

Introduction

It seems like a very long time since Microsoft first announced Whidbey and eventually delivered
the first beta. In fact, it seems like Microsoft is taking a long time to do anything these days. Some
people misinterpret these long delays as a lack of enthusiasm or that perhaps the spark has just
gone out of Microsoft’s development process. One look at the completed Visual Studio and the
many topics discussed in this book should convince you otherwise. Microsoft has done one thing
more than with any other previous release of Visual Studio—they’ve listened. I won’t go so far as

to say that you’ll find every feature of your dreams, but Microsoft has gone a long way toward
making Visual Studio the kind of product that developers will enjoy using.

Mastering Web Development with Microsoft Visual Studio 2005

makes the inevitable transition
easier by pointing out details of all these changes and then providing code to show you how to
use them. Unlike a pure ASP.NET book, you’ll also discover a wealth of techniques for combin-
ing coding methods you use at the desktop with those that you now need to use on the Web site.
While reading and using

Mastering Web Development with Microsoft Visual Studio 2005

, you’ll
create



a large-scale corporate Web site for ABC, Incorporated. In short, instead of simply dis-
covering what ASP.NET provides, you’ll actually put this information into action by building a
complex Web site.

So What’s in Visual Studio for Me?

If you like going home on weekends and don’t like banging your head against the proverbial
brick wall, Visual Studio 2005 has a lot to offer you. Every developer is going to love working
with master pages and themes. The current development process often has developers looking
for odd techniques to get repeated content onto a page. Master pages make the process extremely
fast and easy. The ABC Incorporated Web example used in the majority of this book demonstrates
the full effect of master pages on development. You’ll find that the pages look very consistent,

yet the book will show you that the repeated material is included only once. Themes add to
master pages by letting you give your Web site a consistent feel. Every page uses the same colors
automatically. Of course, you might want to give your users a choice. The ABC Incorporated
Web example that runs through much of this book shows you how to do that too. A simple
change on the main page lets a user switch between any number of themes.
You’ll find the amount of drag-and-drop functionality has increased as well. For example,
you’ll be amazed at how fast you can create complex pages that rely on database input using
drag-and-drop techniques.

Mastering Web Development with Microsoft Visual Studio 2005

shows
you how to improve on drag and drop using SmartTag technology. Simply click an arrow next
to a control to see a SmartTag you can use to configure it. This feature is especially helpful in

4439.book.fm Page xxiii Wednesday, October 19, 2005 12:23 AM

xxiv

INTRODUCTION



getting database applications put together quickly. The ABC Incorporated Web site example
includes a number of database examples—everything from a shopping cart to a beneficial sugges-
tions Web application. In fact, you’ll see just how easy it is to use XML for database purposes in this
example—one of the database examples relies on XML instead of SQL Server.
This book also examines new uses for some existing tools. Many developers aren’t familiar with
everything that Server Explorer can do. Microsoft has made improvements to Server Explorer that
make it a must-use tool for development. You’ll find an entire chapter on this important topic. By

using Server Explorer effectively, you can cut the time required to create any application significantly.
One of the most interesting new features in Visual Studio is WebParts. Imagine providing a little
extra code that lets users move items around, get rid of items they don’t want, and add items back in
when they remove too much—all without bothering you. That’s the beauty of WebParts. You provide
all of the content that anyone will need and the individual users choose what they want. No longer
do you have to contend with requests for little time-consuming tweaks to your Web page design that
someone else will want changed.
I could go on—Visual Studio has a wealth of impressive new Web development features and
you’ll find the majority of them discussed in the book. One of Microsoft’s apparent, less stressed,
goals was obviously to simplify things for the developer. Let’s face it, most developers don’t
have time any longer to fiddle with poorly implemented features.

Mastering Web Development with
Microsoft Visual Studio 2005

helps you understand these new features and get to work quickly using
all of the Visual Studio 2005 functionality.

Goals for Writing this Book

One of the major goals for writing this book is to discover the real world functionality of ASP.NET 2.0.
Rather than simply assume that something probably wouldn’t work or that Visual Studio had a lim-
itation I couldn’t overcome, I assaulted all of the boundaries. The result is this book, which discusses
a broad range of programming topics. In fact, you’ll be surprised at the number of things that Visual
Studio can do—I know that I was pretty amazed by the time I completed this project.
Of course, testing the boundaries is nice, but you need practical examples too. You’ve seen many
examples designed for the corporate market in the past and frankly, at least according to the email
messages I receive, most of them are so hard to understand that it’s a wonder anyone gets anything
out of them at all. Consequently, one of the goals for this book was to create a large-scale example that
anyone can understand. The ABC Incorporated example breaks all of the complex code down into

easily understood parts. The main menu tells you precisely where to find a particular piece of the puzzle
in the book—no guesswork involved. All you need to do is play around with the example, determine
what you’d like to do, and go to that part of the book. It’s really that simple.
Finally, this book helps you discover whether Microsoft is telling the truth about the usefulness
and effectiveness of this product. Is Visual Studio really a good tool for creating Web sites? After all,
you have a lot of tools from which to choose. I think you’ll be surprised at just how easy it is to create
Web sites that not only look professional, but don’t require a lot of time to build. This book demon-
strates that Visual Studio can help you create Web sites of moderate size without the usual array of
widgets and lost time of other products. You can get to work almost immediately and use this book
as a guide while you create the masterpiece that is your Web site.

4439.book.fm Page xxiv Wednesday, October 19, 2005 12:23 AM

×