4439.book.fm Page i Wednesday, October 19, 2005 12:23 AM Mastering Web Development with Microsoft Visual Studio 2005 4439.book.fm Page ii Wednesday, October 19, 2005 12:23 AM 4439.book.fm Page iii Wednesday, October 19, 2005 12:23 AM Mastering ™ Web Development with Microsoft® Visual Studio® 2005 John Paul Mueller Wiley Publishing, Inc. 4439.book.fm Page iv 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 http://www.wiley.com/go/permissions. 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 v 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 vi 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 vii 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 (http://www.freeenewsletters.com/). 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 [email protected]. John is also setting up a Web site at: http://www.mwt.net/~jmueller/; 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 viii 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 ix 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