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

ASP NET 2 0 everyday apps for dummies

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 (9.55 MB, 509 trang )


by Doug Lowe
ASP.NET 2.0
Everyday Apps
FOR
DUMmIES

01_597760 ffirs.qxp 1/11/06 9:48 PM Page iii

by Doug Lowe
ASP.NET 2.0
Everyday Apps
FOR
DUMmIES

01_597760 ffirs.qxp 1/11/06 9:48 PM Page iii
01_597760 ffirs.qxp 1/11/06 9:48 PM Page ii
ASP.NET 2.0
Everyday Apps
FOR
DUMmIES

01_597760 ffirs.qxp 1/11/06 9:48 PM Page i
01_597760 ffirs.qxp 1/11/06 9:48 PM Page ii
by Doug Lowe
ASP.NET 2.0
Everyday Apps
FOR
DUMmIES

01_597760 ffirs.qxp 1/11/06 9:48 PM Page iii


ASP.NET 2.0 Everyday Apps For Dummies
®
Published by
Wiley Publishing, Inc.
111 River Street
Hoboken, NJ 07030-5774
www.wiley.com
Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
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 permit-
ted 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
/>.
Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the
Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, 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.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REP-
RESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CON-
TENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT
LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CRE-
ATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CON-
TAINED 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 FUR-
THER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFOR-
MATION 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, 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.
For technical support, please visit
www.wiley.com/techsupport
.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may
not be available in electronic books.
Library of Congress Control Number: 2005937349
ISBN-13: 978-0-7645-9776-3
ISBN-10: 0-7645-9776-0
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1O/QS/QS/QW/IN
01_597760 ffirs.qxp 1/11/06 9:48 PM Page iv
About the Author
Doug Lowe has written a whole bunch of computer books, including more
than 35 For Dummies books, including the Java All-in-One Desk Reference
For Dummies, Networking For Dummies, 7th Edition, the Networking All-in-One
Desk Reference For Dummies, PowerPoint 2003 For Dummies, and the Word
2003 All-in-One Desk Reference For Dummies. He lives in sunny Fresno,
California, where the motto is, “We almost beat USC!” with his wife, the

youngest of his three daughters, and a couple of outrageously cute puppies.
He is the Information Technology Director for Blair, Church & Flynn, an
engineering firm in nearby Clovis, CA, and he is also one of those obsessive-
compulsive decorating nuts who used to put up tens of thousands of lights at
Christmas until his wife saw the electric bill, so now he creates energy-efficient
computer-controlled Halloween decorations that rival Disney’s Haunted
Mansion.
01_597760 ffirs.qxp 1/11/06 9:48 PM Page v
01_597760 ffirs.qxp 1/11/06 9:48 PM Page vi
Dedication
To Sarah and Hunter.
Author’s Acknowledgments
I’d like to thank everyone involved with making this book a reality, especially
project editor Paul Levesque, who did a great job following through on all the
little editorial details needed to put a book of this scope together on time,
and didn’t panic when the “on time” part of that equation was in question.
Thanks also to Ken Cox, who gave the manuscript a thorough review and
offered many excellent suggestions for improvements, and to copy editor
Barry Childs-Helton, who crossed all the i’s and dotted all the t’s, or some-
thing like that, and in the process somehow turned my strange prose into
readable English. And, as always, thanks to all the behind-the-scenes people
who chipped in with help I’m not even aware of.
01_597760 ffirs.qxp 1/11/06 9:48 PM Page vii
Publisher’s Acknowledgments
We’re proud of this book; please send us your comments through our online registration form
located at
www.dummies.com/register/
.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and

Media Development
Senior Project Editor: Paul Levesque
Acquisitions Editor: Katie Feltman
Copy Editor: Barry Childs-Helton
Technical Editor: Ken Cox
Editorial Manager: Leah Cameron
Media Development Manager:
Laura VanWinkle
Media Development Supervisor:
Richard Graves
Editorial Assistant: Amanda Foxworth
Cartoons: Rich Tennant (
www.the5thwave.com
)
Composition Services
Project Coordinator: Adrienne Martinez
Layout and Graphics: Carl Byers, Andrea Dahl,
Lauren Goddard, Denny Hager,
Joyce Haughey, Barbara Moore,
Lynsey Osborn, Heather Ryan
Proofreaders: Laura Albert, Leeann Harney,
Jessica Kramer, TECHBOOKS Production
Services
Indexer: TECHBOOKS Production Services
Publishing and Editorial for Technology Dummies
Richard Swadley, Vice President and Executive Group Publisher
Andy Cummings, Vice President and Publisher
Mary Bednarek, Executive Acquisitions Director
Mary C. Corder, Editorial Director
Publishing for Consumer Dummies

Diane Graves Steele, Vice President and Publisher
Joyce Pepple, Acquisitions Director
Composition Services
Gerry Fahey, Vice President of Production Services
Debbie Stailey, Director of Composition Services
01_597760 ffirs.qxp 1/11/06 9:48 PM Page viii
Contents at a Glance
Introduction .................................................................1
Part I: Introducing ASP.NET 2.0
Application Development...............................................7
Chapter 1: Designing ASP.NET 2.0 Applications .............................................................9
Chapter 2: Using Visual Studio 2005 ..............................................................................33
Part II: Building Secure Applications ...........................53
Chapter 3: Designing Secure ASP.NET Applications ....................................................55
Chapter 4: Building a User Authentication Application ..............................................79
Part III: Building E-Commerce Applications................105
Chapter 5: Building a Product Catalog Application ...................................................107
Chapter 6: Building a Shopping Cart Application ......................................................143
Part IV: Building Back-End Applications....................221
Chapter 7: Building a Product Maintenance Application..........................................223
Chapter 8: Building a Report Application ...................................................................269
Part V: Building Community Applications...................287
Chapter 9: Building a Content Management System..................................................289
Chapter 10: Building a Web Forum...............................................................................329
Chapter 11: Building a Blog Application......................................................................375
Part VI: The Part of Tens ...........................................423
Chapter 12: Ten New Features of ASP.NET 2.0............................................................425
Chapter 13: Ten Rookie Mistakes .................................................................................445
Chapter 14: Ten Database Design Tips ........................................................................451
Appendix: About the CD ............................................455

Index .......................................................................459
02_597760 ftoc.qxp 1/11/06 9:49 PM Page ix
02_597760 ftoc.qxp 1/11/06 9:49 PM Page x
Table of Contents
Introduction..................................................................1
About This Book...............................................................................................1
Conventions Used in This Book .....................................................................1
How This Book Is Organized...........................................................................2
Part I: Introducing ASP.NET 2.0 Application Development ...............3
Part II: Building Secure Applications ...................................................3
Part III: Building E-Commerce Applications........................................3
Part IV: Building Back-End Applications..............................................3
Part V: Building Community Applications...........................................4
Part VI: The Part of Tens ......................................................................4
About the CD...........................................................................................4
Icons Used in This Book..................................................................................4
Where to Go from Here....................................................................................5
Part I: Introducing ASP.NET 2.0
Application Development ...............................................7
Chapter 1: Designing ASP.NET 2.0 Applications . . . . . . . . . . . . . . . . . . .9
The Development Treadmill .........................................................................10
Building Models..............................................................................................11
What Is an Application Design?....................................................................12
Using Layered Architectures ........................................................................12
How many layers? ................................................................................13
Model-View-Controller .........................................................................15
Designing the user interface ...............................................................16
Designing the Business Rules Layer ..................................................17
Designing the Data Access Layer .......................................................17
Designing Relational Databases ...................................................................18

Step 1: Create a charter for the database..........................................18
Step 2: Make a list and check it twice ................................................19
Step 3: Add keys ...................................................................................21
Step 4: Normalize the database ..........................................................23
Step 5: Denormalize the database......................................................27
Step 6: Pick legal SQL names...............................................................28
Step 7: Draw a picture..........................................................................28
Designing Objects ..........................................................................................29
Diagramming Classes with UML...................................................................29
Drawing classes ....................................................................................31
Drawing arrows.....................................................................................32
02_597760 ftoc.qxp 1/11/06 9:49 PM Page xi
Chapter 2: Using Visual Studio 2005 . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Creating a Basic Hello World Application ...................................................34
Creating a new Web site ......................................................................35
Adding a label control..........................................................................37
Running the application ......................................................................39
Adding a Code-Behind File............................................................................40
Adding a Text Box and a Button...................................................................42
Working with Folders and Other Project Items..........................................46
Debugging Web Applications........................................................................47
Creating a calculator page...................................................................47
Working in Break mode........................................................................49
Displaying data values.........................................................................50
Controlling execution and setting breakpoints ................................51
Deploying ASP.NET Applications .................................................................52
Part II: Building Secure Applications............................53
Chapter 3: Designing Secure ASP.NET Applications . . . . . . . . . . . . . .55
Understanding ASP.NET User Authentication ............................................55
Examining three types of authentication ..........................................56

Configuring forms-based authentication...........................................57
Configuring authorization ...................................................................57
Understanding membership providers .............................................59
Using ASP.NET Login Controls......................................................................60
Using the Login control .......................................................................60
Using the CreateUserWizard control .................................................62
Using the PasswordRecovery control ...............................................66
Using the ChangePassword control ...................................................69
Using the LoginView control ...............................................................72
Using the LoginName control .............................................................73
Using the LoginStatus control.............................................................74
Protecting Against Other Threats ................................................................75
Avoid malicious scripts .......................................................................75
Preventing SQL-injection attacks .......................................................77
Hiding error messages.........................................................................78
Chapter 4: Building a User Authentication Application . . . . . . . . . . . .79
The Application’s User Interface..................................................................80
Designing the User Authorization Application...........................................88
The Application’s Folders .............................................................................88
The web.config Files ......................................................................................89
Building Pages for the User Authentication Application ..........................91
Building the Master Page.....................................................................91
Building the Content page...................................................................93
Building the Admin page .....................................................................94
ASP.NET 2.0 Everyday Apps For Dummies
xii
02_597760 ftoc.qxp 1/11/06 9:49 PM Page xii
Building the Login page .......................................................................95
Building the Register page ..................................................................97
Building the Recover Password page ................................................98

Building the Password Confirmation page......................................100
Building the Change Password page................................................101
Building the User List page ...............................................................102
Part III: Building E-Commerce Applications ................105
Chapter 5: Building a Product Catalog Application . . . . . . . . . . . . . .107
The Application’s User Interface................................................................107
The Product List page........................................................................108
The Product Detail page....................................................................109
The Cart page......................................................................................111
Designing the Product Catalog Application..............................................111
Designing the Product Database................................................................113
The Categories table ..........................................................................113
The Products table.............................................................................114
The FeaturedProducts table .............................................................115
Creating the database........................................................................116
Adding some test data .......................................................................118
Querying the database ......................................................................119
Connecting to the database ..............................................................121
The Application’s Folders ...........................................................................122
Building the Master Page ............................................................................122
Building the Product List Page...................................................................123
The Default.aspx file ..........................................................................124
The code-behind file for the Default.aspx page (C# version).......132
The code-behind file for the Default.aspx page
(Visual Basic version) ....................................................................134
Building the Product Detail page ...............................................................136
The Product.aspx file.........................................................................136
The code-behind file for the Product.aspx page (C# version) .....140
The code-behind file for the Product.aspx page
(Visual Basic version) ....................................................................141

Building the Cart Page .................................................................................142
Chapter 6: Building a Shopping Cart Application . . . . . . . . . . . . . . . .143
Considering Some Basic Decisions ............................................................144
The User Interface........................................................................................145
The Product List page........................................................................146
The Product Detail page....................................................................146
The Cart page......................................................................................146
The Check Out page...........................................................................148
The Completed page ..........................................................................152
xiii
Table of Contents
02_597760 ftoc.qxp 1/11/06 9:49 PM Page xiii
Designing the Cart Database ......................................................................153
The Customers table..........................................................................154
The Orders table.................................................................................155
The OrderItems table.........................................................................156
Creating the database........................................................................157
Adding some test data .......................................................................159
Querying the database ......................................................................159
Inserting order data into the database............................................159
Connecting to the database ..............................................................161
The Application’s Folders ...........................................................................161
Designing the Classes ..................................................................................162
The Customer class............................................................................162
The ShoppingCart class.....................................................................163
The CartItem class .............................................................................164
The Order class ..................................................................................164
The OrderDB class .............................................................................165
Building the Master page ............................................................................165
Modifying the Product Detail Page ............................................................168

Building the Cart Page .................................................................................171
The Cart.aspx file ...............................................................................171
The code-behind file for the Cart page............................................173
Building the Check Out Page ......................................................................181
The CheckOut.aspx file......................................................................181
The code-behind file for the Check Out page .................................189
Creating the Customer Class ......................................................................194
Creating the ShoppingCart Class ...............................................................199
Creating the CartItem Class ........................................................................203
Creating the Order Class .............................................................................207
Creating the OrderDB Class ........................................................................212
Part IV: Building Back-End Applications.....................221
Chapter 7: Building a Product Maintenance Application . . . . . . . . .223
The Application’s User Interface................................................................224
The Menu page ...................................................................................224
The Category Maintenance page......................................................224
The Product Maintenance page........................................................227
Designing the Application...........................................................................229
Designing the Database ...............................................................................231
The Categories table ..........................................................................231
The Products table.............................................................................232
Creating the database........................................................................233
Adding some test data .......................................................................234
SQL statements for the Categories table.........................................235
SQL statements for the Products table ...........................................236
Connecting to the database ..............................................................237
The Application’s Folders ...........................................................................238
ASP.NET 2.0 Everyday Apps For Dummies
xiv
02_597760 ftoc.qxp 1/11/06 9:49 PM Page xiv

Building the Master Page ............................................................................238
Building the Menu Page ..............................................................................239
Building the Category Maintenance Page .................................................240
The CatMaint.aspx file .......................................................................240
The code-behind file for the Catalog Maintenance page...............245
Building the Product Maintenance Page...................................................249
The ProdMaint.aspx file.....................................................................249
The code-behind file for the Product Maintenance page..............265
Chapter 8: Building a Report Application . . . . . . . . . . . . . . . . . . . . . . .269
The Application’s User Interface................................................................270
Designing the Application...........................................................................271
Building the Database..................................................................................272
Designing the database......................................................................272
Creating the database........................................................................274
Adding test data .................................................................................274
SQL statements to retrieve the order data .....................................275
Connecting to the database ..............................................................276
Building the Master Page ............................................................................276
Building the Order User Control ................................................................277
Building the Default Page ............................................................................283
The Default.aspx file ..........................................................................283
The code-behind file for the default page .......................................284
Building the Print Order page.....................................................................286
Part V: Building Community Applications ...................287
Chapter 9: Building a Content Management System . . . . . . . . . . . . .289
Making Some Basic Decisions ....................................................................289
The Content Management System’s User Interface.................................291
The Login page ...................................................................................292
The Home page...................................................................................292
The Department Home page .............................................................293

The Content List page........................................................................294
The Content Detail page ....................................................................295
Designing the Database ...............................................................................297
The Departments table......................................................................297
The ContentTypes table ....................................................................298
The ContentItems table .....................................................................298
Creating the Database .................................................................................299
Adding Test Data ..........................................................................................301
SQL statements for working with the database .............................302
Connecting to the database ..............................................................303
Creating the User Accounts........................................................................303
Building the Master Page ............................................................................304
Building the Login Page...............................................................................307
Building the Home Page ..............................................................................308
xv
Table of Contents
02_597760 ftoc.qxp 1/11/06 9:49 PM Page xv
Building the Department Home Page ........................................................309
Building the Content List Page ...................................................................313
The List.aspx file ................................................................................314
The code-behind file for the Content List page..............................317
Building the Content Detail Page ...............................................................318
The Detail.aspx file.............................................................................319
The code-behind file for the Content Detail page ..........................325
Chapter 10: Building a Web Forum . . . . . . . . . . . . . . . . . . . . . . . . . . . . .329
Designing the Forum Application...............................................................329
The User Interface for the Forum Application .........................................331
The Forum Home page ......................................................................331
The Threads page...............................................................................332
The Messages page ............................................................................332

The New Thread page........................................................................334
The Post Reply page ..........................................................................334
Designing the Database ...............................................................................335
The Forums table ...............................................................................335
The Topics table .................................................................................336
The Threads table ..............................................................................337
The Messages table............................................................................338
Creating the Database .................................................................................338
Adding Test Data ..........................................................................................340
SQL statements for working with the database .............................341
Connecting to the database ..............................................................342
Building the Master Page ............................................................................342
Building the Forum Home Page..................................................................343
The Default.aspx page .......................................................................344
The code-behind file for the Forum Home page.............................346
Building the Threads Page..........................................................................350
The Threads.aspx page......................................................................350
The code-behind file for the Threads page.....................................353
Building the Messages Page........................................................................355
The Messages.aspx page ...................................................................355
The code-behind file for the Messages page ..................................359
Building the New Thread Page ...................................................................360
The NewThread.aspx page................................................................361
The code-behind file for the New Thread page ..............................363
Building the New Message Page.................................................................367
The NewMessage.aspx page .............................................................368
The code-behind file for the New Message page............................371
Chapter 11: Building a Blog Application . . . . . . . . . . . . . . . . . . . . . . . .375
Designing the Blog Application ..................................................................375
Designing the User Interface.......................................................................376

The Blog Home page ..........................................................................376
The Blog page .....................................................................................378
The Comments page ..........................................................................379
The Leave Comment page.................................................................379
ASP.NET 2.0 Everyday Apps For Dummies
xvi
02_597760 ftoc.qxp 1/11/06 9:49 PM Page xvi
The Login page ...................................................................................380
The Register page...............................................................................381
The My Blogs page .............................................................................381
The New Post page.............................................................................383
Designing the Database ...............................................................................383
The Blogs table ...................................................................................384
The Posts table ...................................................................................384
The Comments table..........................................................................385
Creating the Database .................................................................................386
Adding test data .................................................................................388
SQL statements for working with the database .............................389
Connecting to the database ..............................................................390
Building the Master Page ............................................................................390
Building the Blog Home Page .....................................................................392
Building the Blog Page.................................................................................395
The Blog.aspx page ............................................................................395
The code-behind file for the Blog page............................................399
Building the Comments Page......................................................................402
The Comments.aspx page .................................................................402
The code-behind file for the Comments page.................................405
Building the Leave Comment Page ............................................................407
The Comment.aspx page ...................................................................407
The code-behind file for the Leave Comment page .......................409

Building the Login Page...............................................................................410
Building the Register Page ..........................................................................411
Building the My Blogs Page ........................................................................412
The MyBlogs.aspx page.....................................................................413
The code-behind file for the My Blogs page ...................................416
Building the New Post Page ........................................................................418
The NewPost.aspx page.....................................................................418
The code-behind file for the New Post page...................................421
Part VI: The Part of Tens............................................423
Chapter 12: Ten New Features of ASP.NET 2.0 . . . . . . . . . . . . . . . . . . .425
The New Code-Behind Model .....................................................................426
App_ Folders.................................................................................................427
Master Pages.................................................................................................428
Creating a Master Page......................................................................429
Completing a Master Page.................................................................430
Creating a Content page ....................................................................431
New Data Controls .......................................................................................432
The SqlDataSource control ...............................................................433
The GridView control.........................................................................436
The DetailsView control ....................................................................438
The FormView Control.......................................................................439
Login Controls ..............................................................................................440
xvii
Table of Contents
02_597760 ftoc.qxp 1/11/06 9:49 PM Page xvii
The Wizard Control......................................................................................440
The Generics Feature...................................................................................441
The Web Site Administration Tool .............................................................443
Chapter 13: Ten Rookie Mistakes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .445
Coding Too Soon ..........................................................................................445

Skimping On Documentation......................................................................446
Inadequate Testing.......................................................................................447
Abusing State Features................................................................................447
Not Validating Input Data ............................................................................448
Reinventing the Wheel.................................................................................448
Not Asking for Help......................................................................................449
Chapter 14: Ten Database Design Tips . . . . . . . . . . . . . . . . . . . . . . . . .451
Use the Right Number of Tables.................................................................451
Avoid Repeating Data ..................................................................................452
Avoid Redundant Data.................................................................................452
Use a Naming Convention ...........................................................................452
Avoid nulls ....................................................................................................453
Avoid Secret Codes ......................................................................................453
Use Constraints Wisely................................................................................454
Use Triggers When Appropriate.................................................................454
Use Stored Procedures ................................................................................454
Appendix: About the CD.............................................455
System Requirements..................................................................................455
Using the CD .................................................................................................456
Using the Source Files .................................................................................456
Troubleshooting...........................................................................................457
Index........................................................................459
ASP.NET 2.0 Everyday Apps For Dummies
xviii
02_597760 ftoc.qxp 1/11/06 9:49 PM Page xviii
Introduction
W
elcome to ASP.NET 2.0 Everyday Apps For Dummies, the book that
teaches ASP.NET 2.0 Web programming by example. In this book,
you’ll find eight complete ASP.NET applications. We’re not talking trivial

Hello-World-type applications here. Instead, they’re real-world applications
like shopping carts and discussion forums. You can use any of them as-is, or
modify them as you see fit. So you’ve got workable stuff already included.
(What a concept.)
About This Book
This book is a practical introduction to ASP.NET 2.0 Web programming. It pro-
vides you with actual working code to build the most popular types of appli-
cations on the Web. These applications enable you to:
ߜ Restrict access to registered users, for all or part of your Web site
ߜ Sell products online via your Web site
ߜ Provide back-end functions for your public Web site, such as file mainte-
nance and reporting
ߜ Let users manage specific types of online content
ߜ Create discussion forums and blogs
ASP.NET 2.0 Everyday Apps For Dummies doesn’t pretend to be a comprehen-
sive reference for every detail of ASP.NET programming. Instead, it takes a
learn-by-example approach, under the assumption that you are already a
pretty competent programmer who can best learn by seeing real-world exam-
ples. Designed using the easy-to-follow For Dummies format, this book helps
you get the information you need without laboring to find it.
Conventions Used in This Book
This book has a lot of code in it. You’ll find complete listing of every line of
code, both C# and Visual Basic, for each of the eight applications presented
in this book. You’ll also find listings for supporting files such as SQL scripts
to generate databases and web.config files that provide configuration infor-
mation for the applications.
03_597760 intro.qxp 1/11/06 9:49 PM Page 1
Most of these listings include reference numbers that correspond to num-
bered explanations in the text. In most cases, these explanations apply to
both the C# and the Visual Basic versions of the code. (For example, the code

explanation identified with reference number 3 applies to the line indicated
with reference number 3 in both the C# and the Visual Basic versions of the
listing.)
To keep page-flipping to a minimum, I always present the C# version of a list-
ing first, followed by the text that explains it, followed by the Visual Basic list-
ing. Thus, if you’re a C# programmer, you can flip forward from your listing to
the text that explains it. And if you’re a Visual Basic programmer, you can flip
backward from your listing to the corresponding blow-by-blow description.
On occasion, I’ll show a console prompt along with commands you need to
enter. In that case, the command is presented as follows:
sqlcmd -S localhost\SQLExpress -s createdb.sql
How This Book Is Organized
This book is divided into six parts, with two or three chapters in each part.
Chapters 4 through 11 present the applications themselves. In these particu-
lar chapters, you’re going to find the same basic structure, which (hopefully)
gets the following information across for each one:
ߜ A discussion of design issues for the application.
ߜ An overview of the application’s user interface, including a diagram that
shows the flow of the application’s pages, along with images of each
page.
ߜ A description of the design for the database used by the application,
along with listings of the scripts used to create the database and popu-
late it with sample test data.
ߜ Listings of the .aspx files for each of the application’s pages.
ߜ Where appropriate, listings of the code-behind file in both C# and Visual
Basic.
ߜ Explanations of the key parts of the listings.
If you’re up for a quick summary, the following sections offer a bird’s-eye
view of what you can find in each part of the book.
2

ASP.NET 2.0 Everyday Apps For Dummies
03_597760 intro.qxp 1/11/06 9:49 PM Page 2

×