Table Of Content01_749516 ffirs.qxp 2/16/06 5:57 PM Page i
ASP.NET 2.0
Instant Results
Imar Spaanjaars, Paul Wilton, and Shawn Livermore
01_749516 ffirs.qxp 2/16/06 5:57 PM Page i
01_749516 ffirs.qxp 2/16/06 5:57 PM Page i
ASP.NET 2.0
Instant Results
Imar Spaanjaars, Paul Wilton, and Shawn Livermore
01_749516 ffirs.qxp 2/16/06 5:57 PM Page ii
ASP.NET 2.0 Instant Results
Published by
WWiilleeyy PPuubblliisshhiinngg,, IInncc..
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN-13: 978-0-471-74951-6
ISBN-10: 0-471-74951-6
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1MA/QS/QT/QW/IN
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 Sec-
tions 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Pub-
lisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222
Rosewood Drive, Danvers, MA01923, (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.
LLIIMMIITT OOFF LLIIAABBIILLIITTYY//DDIISSCCLLAAIIMMEERR OOFF WWAARRRRAANNTTYY::THE PUBLISHER AND THE AUTHOR MAKE
NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACYOR COMPLETENESS
OF THE CONTENTS OF THIS WORK AND SPECIFICALLYDISCLAIM ALLWARRANTIES, INCLUDING
WITHOUT LIMITATION WARRANTIES OF FITNESS FOR APARTICULAR PURPOSE. NO WARRANTY
MAYBE CREATED OR EXTENDED BYSALES OR PROMOTIONALMATERIALS. THE ADVICE AND
STRATEGIES CONTAINED HEREIN MAYNOT BE SUITABLE FOR EVERYSITUATION. THIS WORK IS
SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING
LEGAL, ACCOUNTING, OR OTHER PROFESSIONALSERVICES. IF PROFESSIONALASSISTANCE IS
REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT.
NEITHER THE PUBLISHER NOR THE AUTHOR SHALLBE LIABLE FOR DAMAGES ARISING HERE-
FROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A
CITATION AND/OR APOTENTIALSOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT
THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR
WEBSITE MAYPROVIDE OR RECOMMENDATIONS IT MAYMAKE. FURTHER, READERS SHOULD BE
AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAP-
PEARED 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.
LLiibbrraarryy ooff CCoonnggrreessss CCaattaalloogg NNuummbbeerr:: 2006003345
TTrraaddeemmaarrkkss::Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress
are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, 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.
FCKeditor–The text editor for the Internet. Copyright © 2003-2006 Frederico Caldeira Knabben. Licensed
under the terms of the GNU Lesser General Public License (LGPL).
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not
be available in electronic books.
01_749516 ffirs.qxp 2/16/06 5:57 PM Page iii
About the Authors
IImmaarr SSppaaaannjjaaaarrssgraduated in Leisure Management from the Leisure Management School in the
Netherlands, but quickly changed his career path into the Internet world. After working for a large cor-
poration and doing some freelance work, he is now working for Design IT, an IT company in the
Netherlands that specializes in Internet and Intranet applications built with Microsoft technologies like
ASP.NET. As a software designer and lead developer, he’s responsible for designing, building, and
implementing medium- to large-scale e-commerce web sites and portals.
Before this book on ASP.NET 2.0, Imar wrote two books about Macromedia Dreamweaver, called
Beginning Dreamweaver MXand Beginning Dreamweaver MX 2004, both published under the Wrox brand.
Imar is also one of the top contributors to the Wrox Community Forums at http://p2p.wrox.com
where he shares his knowledge with fellow programmers.
Imar lives in Utrecht, the Netherlands, together with his girlfriend Fleur. You can contact him through
his web site at http://imar.spaanjaars.com.
PPaauull WWiillttoonngot an initial start as a Visual Basic applications programmer at the Ministry of Defense in
the UK before finding himself pulled into the Net. Having joined an Internet development company, he
spent three years helping create Internet solutions. He’s now running his own company developing
online holiday property reservation systems.
Paul’s main skills are in developing web front ends using DHTML, JavaScript, and VBScript as well as
back-end solutions with ASP, ASP.NET, Visual Basic, and SQLServer.
SShhaawwnn LLiivveerrmmoorree(MCAD, MCSD, PMP) [shawnlivermore.blogspot.com] has been architecting and
developing Microsoft-based solutions for nearly a decade. Shawn consults as an architect for Fortune
500 clientele, leveraging time-proven methodologies and exceptional communications, within highly
visible projects. His range of technical competence stretches across platforms, but specializes within
Microsoft .NET development and server-based products such as Biztalk and SQLServer, among others.
His experience implementing enterprise-level Microsoft solutions is extensive and has led to successful
business ventures with numerous firms. Shawn lives in the Southern California area with his beautiful
wife Shantell and amazing daughter Elexzandreia.
iii
01_749516 ffirs.qxp 2/16/06 5:57 PM Page iv
Credits
Senior Acquisitions Editor Project Coordinator
Jim Minatel Michael Kruzil
Development Editor Graphics and Production Specialists
Brian Herrmann Lauren Goddard
Brooke Graczyk
Technical Editors Denny Hager
Dan Maharry and Scott Spradlin Joyce Haughey
Barbara Moore
Production Editor Alicia B. South
Felicia Robinson
Quality Control Technicians
Copy Editor Jessica Kramer
Kim Cofer Brian Walls
Editorial Manager Media Development Project Supervisor
Mary Beth Wakefield Shannon Walters
Production Manager Media Development Specialist
Tim Tate Steven Kudirka
Vice President and Executive Group Publisher Proofreading and Indexing
Richard Swadley TECHBOOKS Production Services
Vice President and Executive Publisher
Joseph B. Wikert
01_749516 ffirs.qxp 2/16/06 5:57 PM Page v
Imar Spaanjaars: To Fleur - The love of my life.
Shawn Livermore: This book is dedicated to my Lord Jesus, who has mastered all things, much
less a simple piece of software.
Paul Wilton: With lots of love to my darling Beci, who now the book’s finished will get to see
me for more than 10 minutes a week.
Acknowledgments
Imar Spaanjaars
Writing a book like this one is definitely not a solo project. During development of this book I got a lot of
support from many people who helped me to stay focused and get inspiration. I would like to give all of
you that helped a big thanks! While I can’t possibly thank all of you here personally, there are a few peo-
ple I’d like to thank in particular.
First of all I’d like to thank the people at Wiley for working with me on this project, with Brian
Herrmann in particular for his efforts during the editorial process.
I would also like to thank Anne Ward for helping me with the designs of some of the applications fea-
tured in this book.
Abig thanks goes out to the people at Design IT for their participation in my “hallway usability tests”
that I randomly brought up in the office. Thanks guys! It’s always good to have a few extra sets of eyes.
My appreciation also goes out to my two good friends René and Joost for their friendship. Looking for-
ward to spending more time with you again.
Last but certainly not least, I would like to thank my girlfriend Fleur for her support during this project.
I know it wasn’t always fun when I disappeared in my home office for hours, but you were a great sup-
porter and motivator nonetheless.
IImmaarr SSppaaaannjjaaaarrss ccoonnttrriibbuutteedd CChhaapptteerrss 55,, 66,, aanndd 88––1122 ttoo tthhiiss bbooookk..
01_749516 ffirs.qxp 2/16/06 5:57 PM Page vi
Acknowledgments
Paul Wilton
I’d like to say a very big thank you to Brian Herrmann, who has been a great editor to work with and
has done amazing work on the book. He manages to maintain professionalism and sense of humor even
when faced with another of my “just a few more days and I’ll get the chapter to you” e-mails!
Thanks also to Jim Minatel for making this book happen, and also his support in what has for me been a
challenging and difficult year.
Many thanks to everyone who has supported and encouraged me over the many years of writing books.
Your help will always be remembered.
Finally, pats and treats to my German Shepherd Katie, who does an excellent job warding off distur-
bances from door-to-door salespeople.
PPaauull WWiillttoonn ccoonnttrriibbuutteedd CChhaapptteerr 11 ttoo tthhiiss bbooookk..
Shawn Livermore
I thank my gorgeous wife Shantell, who is a truly beautiful and caring person, and has always encour-
aged me to shoot higher. Your love has changed my life. Thanks for supporting me through the long
hours and boring computer nerd conversations. I owe you a pair of Gucci shoes. And of course, to my
daughter Elexzandreia, who is a gift from heaven. You have taught me so much about life and have
made me want to be a better dad. I love you “134,000.”
SShhaawwnn LLiivveerrmmoorree ccoonnttrriibbuutteedd tthhee IInnttrroodduuccttiioonn aanndd CChhaapptteerrss 22––44 aanndd 77 ttoo tthhiiss bbooookk..
vi
02_749516 ftoc.qxp 2/10/06 9:10 PM Page vii
Contents
Acknowledgments v
Introduction xvii
Chapter 1: The Online Diary and Organizer 1
Using the Online Diary 1
Design of the Online Diary 6
The Data Access Layer 6
The Business Layer 8
The OnlineDiary Class 8
The Contact Class 8
The ContactCollection Class 10
The DiaryEntry Class 11
The DiaryEntryCollection Class 13
The DiaryEvent Class 14
The DiaryEventCollection Class 16
Code and Code Explanation 17
File Structure 17
Registration,Logging On,and Security 18
Logging On 18
New User Registration 19
Password Reminder 23
Viewing the Online Calendar 24
Creating,Editing,and Viewing a Diary Entry 26
Creating,Editing,and Viewing Diary Events 29
Managing Contacts 32
Setting up the Online Diary 34
Summary 35
Chapter 2: Wrox File Share 37
Using the Wrox File Share 38
Wrox File Share Design 41
Uploading Files 41
Sending E-Mails 42
Structure of the Site 43