The Microsoft Expression Web Developer's Guide to ASP.NET 3.5: Learn to create ASP.NET applications using Visual Web Developer 2008by Jim Cheshire Publisher: Que Pub Date: November 02, 2
Trang 1The Microsoft Expression Web Developer's Guide to ASP.NET 3.5: Learn to create ASP.NET applications using Visual Web Developer 2008
by Jim Cheshire
Publisher: Que Pub Date: November 02, 2007 Print ISBN-10: 0-7897-3665-9 Print ISBN-13: 978-0-7897-3665-9 Pages: 504
Mikhail Arkhipov
Principal Development Manager – Web Development ToolsMicrosoft Corporation
Expression Web introduced ASP.NET to a new group of webdevelopers This book is designed to help you start using
ASP.NET right away to add powerful new features to your
website Don't worry, you won't have to learn a lot of
programming; instead, you'll create an ASP.NET application
Trang 2• Create and work with websites in Visual Web Developer2008
ON THE WEB:
Download examples and source code presented in this book
Trang 3Beginning to Intermediate
Trang 4Guide to ASP.NET 3.5: Learn to create ASP.NET applications using Visual Web Developer 2008
by Jim Cheshire
Publisher: Que
Pub Date: November 02, 2007
Print ISBN-10: 0-7897-3665-9 Print ISBN-13: 978-0-7897-3665-9 Pages: 504
Trang 5The Web Site Administration Tool
ASP.NET Configuration in IIS
Encrypting Information in the Configuration FilesChapter 7 Basic ASP.NET Security
The Structure of an ASP.NET Website
Creating a Web Application in Visual Web DeveloperStart Options in Visual Web Developer
Chapter 9 Creating ASP.NET Web Forms
Trang 6Choosing the Right Tool for ASP.NET ApplicationDevelopment
Checkpoint
Chapter 13 Adding and Managing Users and RolesUsers and Roles
Configuring Authentication
Adding New Users
Enabling and Adding Roles
Configuring Access Rules
Trang 7Common Validation Control Properties
Adding and Configuring ASP.NET Validation ControlsCheckpoint
Part VI: Styling Web Forms in Visual Web Developer 2008Chapter 17 Creating and Managing CSS Styles
Trang 11The Expression Web Developer's Guide to ASP.NET
Copyright © 2008 by Que Publishing
All rights reserved No part of this book shall be reproduced,stored in a retrieval system, or transmitted by any means,
electronic, mechanical, photocopying, recording, or otherwise,without written permission from the publisher No patent
liability is assumed with respect to the use of the informationcontained herein Although every precaution has been taken inthe preparation of this book, the publisher and author assume
no responsibility for errors or omissions Nor is any liability
assumed for damages resulting from the use of the informationcontained herein
as affecting the validity of any trademark or service mark
Warning and Disclaimer
Every effort has been made to make this book as complete and
as accurate as possible, but no warranty or fitness is implied.The information provided is on an "as is" basis The author andthe publisher shall have neither liability nor responsibility to anyperson or entity with respect to any loss or damages arising
Trang 12Bulk Sales
Que Publishing offers excellent discounts on this book whenordered in quantity for bulk purchases or special sales Formore information, please contact
Trang 14You can contact Jim via either of his websites
Trang 15To Mikhail Arkhipov and others on the Visual Web Developerteam at Microsoft, thank you for answering my questions andsharing your excitement with me I hope I did the product
justice in this book
To Mike Coleman, my boss at Microsoft, thank you for
supporting my work on this project
To my family, after two books back to back, I know how tiredyou must be of hearing me say "I'd like to, but I have to write."Thank you for giving me the time and for being patient with meduring those times when I was pushing a tight deadline and not
in the best of moods I love all of you so much
I'd like to thank my parents for their never-ending confidence in
me and for encouraging their friends (who know nothing abouttechnology) to buy my books
Last, but certainly not least, to my readers; thank you for
buying my book and making all the work that went into thisbook worth something Without you, all the commitment fromthose involved in this project would be for naught
Trang 16As the reader of this book, you are our most important critic
and commentator We value your opinion and want to know
what we're doing right, what we could do better, what areasyou'd like to see us publish in, and any other words of wisdomyou're willing to pass our way
As an associate publisher for Que Publishing, I welcome yourcomments You can email or write me directly to let me knowwhat you did or didn't like about this book[md]as well as what
we can do to make our books better
Please note that I cannot help you with technical problems
related to the topic of this book We do have a User Services group, however, where I will forward specific technical
questions related to the book.
When you write, please be sure to include this book's title andauthor as well as your name, email address, and phone number
I will carefully review your comments and share them with theauthor and editors who worked on the book
Trang 17Visit our website and register this book at
www.informit.com/title/9780789736659 for convenient access
to any updates, downloads, or errata that might be available forthis book
Trang 18Because Expression Web added support for ASP.NET
development, many Expression Web users who were migratingfrom FrontPage saw ASP.NET as a natural transition from theFrontPage components that they had grown so used to
Unfortunately, they quickly found themselves overwhelmed withASP.NET Let's face it: Most FrontPage users migrating to
Expression Web are not programmers and don't want to becomeprogrammers Instead, they want to take advantage of the
technologies exposed in Expression Web without having to
spend months learning how to write code
If you can relate to the previous two paragraphs, this book isfor you! This book is designed to walk you through creating anASP.NET web application from beginning to end, using MicrosoftVisual Web Developer Express Edition, (referred to as simplyVisual Web Developer from here on out.) Visual Web Developerhas many of the designer features and CSS features that you'llfind in Expression Web, but it's much better suited to designingASP.NET applications
Here are some of the ASP.NET features this book covers:
Creating ASP.NET websites
Trang 19Accessing databases with ASP.NET
Editing database data with ASP.NET
Using ASP.NET membership to password protect parts of awebsite
Sending email with ASP.NET
Using ASP.NET Ajax 1.0
Much more
I'll show you how to implement all these features while writingthe least amount of code possible, but when code is necessary,I'll provide samples in both Visual Basic and C#
Trang 20Because Expression Web added support for ASP.NET
development, many Expression Web users who were migratingfrom FrontPage saw ASP.NET as a natural transition from theFrontPage components that they had grown so used to
Unfortunately, they quickly found themselves overwhelmed withASP.NET Let's face it: Most FrontPage users migrating to
Expression Web are not programmers and don't want to becomeprogrammers Instead, they want to take advantage of the
technologies exposed in Expression Web without having to
spend months learning how to write code
If you can relate to the previous two paragraphs, this book isfor you! This book is designed to walk you through creating anASP.NET web application from beginning to end, using MicrosoftVisual Web Developer Express Edition, (referred to as simplyVisual Web Developer from here on out.) Visual Web Developerhas many of the designer features and CSS features that you'llfind in Expression Web, but it's much better suited to designingASP.NET applications
Here are some of the ASP.NET features this book covers:
Creating ASP.NET websites
Trang 21Accessing databases with ASP.NET
Editing database data with ASP.NET
Using ASP.NET membership to password protect parts of awebsite
Sending email with ASP.NET
Using ASP.NET Ajax 1.0
Much more
I'll show you how to implement all these features while writingthe least amount of code possible, but when code is necessary,I'll provide samples in both Visual Basic and C#
Trang 22This book is divided into multiple sections so that you can
quickly find the information you need Here is the rundown onall the sections:
Part I, "Understanding ASP.NET Architecture"— I cover thebasics of ASP.NET You'll learn about ASP.NET code models,compilation models, how ASP.NET page events work, howASP.NET is configured, and the basics of ASP.NET security.Part II, "Creating ASP.NET Applications and Web Forms"—
In this section, I cover creating ASP.NET websites and
ASP.NET Web forms
Part III, "Master Pages and User Controls"— I cover creatingWeb forms with master pages, a new feature introduced inASP.NET 2.0 I also cover creating and using reusable
ASP.NET components called user controls
Part IV, "ASP.NET Membership"— In this section I cover thesecurity features of ASP.NET more closely You'll create
users and roles (ASP.NET groups) and configure their access
to the website You'll also create a login page and other
pages to allow users to manage user accounts
Part V, "ASP.NET Forms and Validation"— In this sectionyou'll learn how to create custom forms in ASP.NET and how
to use the ASP.NET validation controls to configure formvalidation
Part VI, "Styling Web Forms in Visual Web Developer"— Inthis section you'll learn how to use the powerful CSS toolsetthat Expression Web brings to Visual Web Developer I alsocover ASP.NET skins and themes
Part VII, "Data Access with ASP.NET"— In this section I
cover the ASP.NET data controls and how to display, add,edit, and delete data from a database
Trang 23Part IX, "Debugging and Troubleshooting ASP.NET"—
Realizing that things will go terribly wrong when you leastexpect it, this section covers debugging and troubleshootingASP.NET applications
Part X, "Deploying ASP.NET Applications"— In this section, Icover deploying your ASP.NET application to another webserver
I've also included one appendix that covers all the various
options and settings available in Visual Web Developer
Special Elements
Throughout the book, you'll find some special elements that aredesigned to make it easy to locate important information orspecial tips that help you get the most out of Visual Web
Developer
When a special term is used for the first time, it is printed in
italic and is defined close by If instructions require you to enter
text or values into a dialog, the data you are to enter appearslike this
Cross References
This book is designed to be read in order, but you may still findyourself wanting to read up on a specific topic in advance or goback and review a topic covered in a previous chapter For thatreason, I've made sure to cross-reference information wherepossible
Notes, Tips, Cautions, and Sidebars
You'll find numerous bits of information in these special
elements
Trang 24Notes include additional technical information or URLsthat you can use to access important information
Trang 25designed to give you more insight into a particular topic
If you're the kind of person who wants to know all the
details, you'll find sidebars to be extremely valuable
I've worked hard to make this book the definitive resource onASP.NET for Expression Web users who don't want to becomeASP.NET programmers I hope this book will excite you aboutdesigning ASP.NET applications and adding a whole new realm
of possibilities to your web design toolset
—Jim
Trang 26Part I: Understanding ASP.NET Architecture
Trang 27dabbled in writing code from time to time, few have becomecompetent enough to actually be considered software
developers The reason is simple: Programming technologiesare often obscure and complex and becoming proficient in theuse of them can involve years of study
Over the years, several software companies have attempted tomake it easier to develop rich applications quickly without
having to deal with the complexities of computer architectures.Most of these attempts have met with failure or only limitedsuccess
Trang 28developers to quickly and easily develop desktop applicationsand web applications By providing common libraries for manyprogramming tasks, the NET Framework makes it easy to buildrobust applications rapidly As you progress through this book,you'll get a good idea of just how much power the NET
Trang 29Before we go into the details of developing ASP.NET
applications, you'll want to make sure that you have a web
server configured to run ASP.NET applications All operatingsystems from Windows 2000 up support the use of the ASP.NETDevelopment Server Table 1.1 shows the web server choicesyou have in addition to the ASP.NET Development Server foreach operating system
Trang 30Part I: Understanding ASP.NET Architecture
Trang 31dabbled in writing code from time to time, few have becomecompetent enough to actually be considered software
developers The reason is simple: Programming technologiesare often obscure and complex and becoming proficient in theuse of them can involve years of study
Over the years, several software companies have attempted tomake it easier to develop rich applications quickly without
having to deal with the complexities of computer architectures.Most of these attempts have met with failure or only limitedsuccess
Trang 32developers to quickly and easily develop desktop applicationsand web applications By providing common libraries for manyprogramming tasks, the NET Framework makes it easy to buildrobust applications rapidly As you progress through this book,you'll get a good idea of just how much power the NET
Trang 33Before we go into the details of developing ASP.NET
applications, you'll want to make sure that you have a web
server configured to run ASP.NET applications All operatingsystems from Windows 2000 up support the use of the ASP.NETDevelopment Server Table 1.1 shows the web server choicesyou have in addition to the ASP.NET Development Server foreach operating system
Trang 34Part I: Understanding ASP.NET Architecture
Trang 35dabbled in writing code from time to time, few have becomecompetent enough to actually be considered software
developers The reason is simple: Programming technologiesare often obscure and complex and becoming proficient in theuse of them can involve years of study
Over the years, several software companies have attempted tomake it easier to develop rich applications quickly without
having to deal with the complexities of computer architectures.Most of these attempts have met with failure or only limitedsuccess
Trang 36developers to quickly and easily develop desktop applicationsand web applications By providing common libraries for manyprogramming tasks, the NET Framework makes it easy to buildrobust applications rapidly As you progress through this book,you'll get a good idea of just how much power the NET
Trang 37Before we go into the details of developing ASP.NET
applications, you'll want to make sure that you have a web
server configured to run ASP.NET applications All operatingsystems from Windows 2000 up support the use of the ASP.NETDevelopment Server Table 1.1 shows the web server choicesyou have in addition to the ASP.NET Development Server foreach operating system
Trang 38The files that are required to run ASP.NET applications are
installed when the NET Framework is installed However,
ASP.NET must be configured on the web server before you canrun ASP.NET applications If you already have your web serverinstalled when you install the NET Framework, ASP.NET will beautomatically configured for you in most cases
15
Tip
Trang 39won't hurt anything if you configure it again
Configuring ASP.NET on IIS 5.1 or IIS 6.0
If you are using IIS 5.1 (on Windows XP Professional) or IIS 6,you configure ASP.NET by using a command-line utility called
aspnet_regiis.exe If IIS is installed when the NET
Framework is installed, this happens for you automatically.However, if you install IIS after you've installed the NET
Framework, you need to manually configure ASP.NET
Tip
The NET Framework is automatically installed when youinstall Visual Web Developer
Note
I don't cover the details of managing IIS in this book Ifyou're interested in thorough coverage of using and
Trang 40the NET Framework To use ASP.NET 3.5, you will need
to run aspnet_regiis.exe as described in this chapter
The aspnet_regiis.exe utility is run from a command line,using command-line parameters To configure ASP.NET 3.5, youwill need to run the aspnet_regiis.exe utility from the installdirectory for the 2.0 version of the NET Framework becausethere isn't a new ASP.NET runtime in the NET Framework
Table 1.3 aspnet_regiis.exe Command
Line Parameters