HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
Adobe® Digital Editions software.
This eBook requires the freeBefore downloading this DRM-encrypted PDF, be sure to:
“This book is a great reference for web designers new to ASP.NET who are looking to jump start their development with
Visual Web Developer 2008.”
Mikhail Arkhipov
Principal Development Manager – Web Development Tools
Microsoft Corporation
Expression Web introduced ASP.NET to a new group of web developers. 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 from start to finish using Visual Web Developer 2008, while writing only a very small amount of actual programming code.
DETAILED INFORMATION ON HOW TO…
• Create and work with websites in Visual Web Developer 2008
• Use the different compilation and code models in ASP.NET
• Configure ASP.NET security and other settings
• Use ASP.NET master pages and user controls
• Take advantage of ASP.NET membership features for a password-protected website
• Use form validation in ASP.NET
• Use CSS, skins, and themes
• Access, edit, and add data to a database using ASP.NET
• Send email using ASP.NET
• Use Ajax and ASP.NET Web services
• Debug and troubleshoot ASP.NET
. . . and much more!
Introduction
Part I Understanding ASP.NET Architecture
Chapter 1 Installing and Configuring ASP.NET
Understanding the .NET Framework and ASP.NET
Configuring ASP.NET
Configuring ASP.NET on IIS 5.1 or IIS 6.0
Configuring ASP.NET on IIS 7
Using the ASP.NET Development Server
Troubleshooting IIS
Chapter 2 ASP.NET Code Models
Understanding ASP.NET Web Form Code
ASP.NET Directives
ASP.NET Design-Time Code
Server-Side Code Models
Inline Server-Side Code
Code-Behind Server-Side Code
Switching Server-Side Code Models
Moving from Code-Behind to Inline Code
Moving from Inline Code to Code-Behind
Choosing a Code Model
Chapter 3 ASP.NET Compilation Models
ASP.NET Compilation
The Web Application Compilation Model
The Website Compilation Model
The Precompilation Model
Automating aspnet_compiler.exe in Visual Web Developer Express Edition
Chapter 4 ASP.NET Events and the Page Lifecycle
An Event-Driven Architecture
Application and Session Events
Application Events and the Application Lifecycle
Session Events
Page Events and the Page Lifecycle
The Importance of the Lifecycle
Investigating the Page Lifecycle
Chapter 5 ASP.NET State Management
A Connectionless Environment
Understanding Application Variables
Setting an Application Variable
Retrieving an Application Variable
Understanding Session Variables
Using ASP.NET Caching
Page Output Caching
Fragment Caching
The Cache API
Retrieving Items from Cache
ASP.NET Viewstate and Control State
Chapter 6 ASP.NET Configuration and Performance
Overview of ASP.NET Configuration
ASP.NET Configuration Files
Machine Configuration Files
Application Configuration Files
The Web Site Administration Tool
Security Tab
Application Tab
Provider Tab
ASP.NET Configuration in IIS
IIS 5.1 and IIS 6
IIS 7
Encrypting Information in the Configuration Files
Chapter 7 Basic ASP.NET Security
Authentication and Authorization
Configuring Windows Authentication
Disabling Anonymous Browsing in IIS 5 and 6
Disabling Anonymous Browsing in IIS 7 (Windows Vista)
Understanding Forms Authentication
Configuring Forms Authentication
Configuring Forms Authentication with the ASP.NET Web Site Administration Tool
Configuring Forms Authentication with the ASP.NET Configuration Settings Dialog (IIS 5 or 6 Only)
Configuring Forms Authentication with the IIS Manager (IIS 7 Only)
Other Forms Authentication Settings
ASP.NET Authorization
Configuring Authorization with the ASP.NET Configuration Settings Dialog (IIS 5 and 6 Only)
Configuring Authorization with the IIS Manager (IIS 7 Only)
Why Not Windows Authentication?
Part II Creating ASP.NET Applications and Web Forms
Chapter 8 Creating Websites
The Structure of an ASP.NET Website
Special Folders in an ASP.NET Application
Creating a Web Application in Visual Web Developer
File System
Local IIS
FTP
Remote Site
Start Options in Visual Web Developer
Start Actions
Server Options
Chapter 9 Creating ASP.NET Web Forms
Creating Web Forms in Visual Web Developer
Creating ASP.NET Web Forms
Other File Types Available in Visual Web Developer
Creating Web Pages in Expression Web
Choosing the Right Tool for ASP.NET Application Development
Using the Code-Behind Model
Using the Inline Code Model
A Suggested Workflow
Use Either Tool to Create the Website
Use Visual Web Developer to Create Pages
Do Design Work in Either Tool
Use Either Tool to Configure ASP.NET Controls
Use Either Tool to Preview Your Pages
Test ASP.NET Code in Visual Web Developer
Publish Your Website with Expression Web
Part III Master Pages and User Controls
Chapter 10 Creating and Using Master Pages
An Introduction to Master Pages
Structure of Master Pages and Content Pages
Creating a Master Page
Adding Content to the Master Page
Formatting the Master Page
Configuring Navigation Controls
Creating a Sitemap File
Configuring the Menu to Use the Sitemap File
Connecting a Page to the Master Page
Connecting a New Page
Connecting an Existing Page
Checkpoint
Chapter 11 Creating and Using User Controls
What Are User Controls?
Creating a User Control
Adding User Controls to a Page
Creating a User Control
Editing a User Control
Converting a Page to a User Control
Checkpoint
Part IVASP.NET Membership
Chapter 12 Configuring a Membership Database
An Introduction to ASP.NET Membership
The Membership Provider
Using the Default Membership Database
Using SQL Server 2000 or SQL Server 2005 for Membership
Configuring the Database
Configuring the Provider for the New Database
Configuring the Connection String in IIS 5 or IIS 6
Configuring the Connection String in IIS 7
Configuring the Connection String in a Disk-based Application
Checkpoint
Chapter 13 Adding and Managing Users and Roles
Users and Roles
Configuring Authentication
Adding New Users
Enabling and Adding Roles
Enabling Roles
Creating Roles
Adding a User to a Role
Configuring Access Rules
What Happens Under the Hood?
Configuring Authentication
Enabling Roles
Creating Access Rules
Checkpoint
Chapter 14 Adding and Configuring Login and User Management Pages
Configuring the Login Control
Configuring the Appearance of the Login Control
Configuring the Behavior of the Login Control
Using the LoginView Control
Creating Accounts Using the CreateUserWizard Control
Adding the Create User Page
Adding a Confirmation Page
Resetting Lost Passwords
Creating the Password Recovery Page
Configuring ASP.NET for Sending Email
Changing Passwords
A Few Finishing Touches
Adding a Link to Reset Password
Adding a Change Password Link
Fixing the Logo Graphic on the Master Page
Checkpoint
Part VASP.NET Forms and Validation
Chapter 15 Creating Forms Using ASP.NET
Introduction to ASP.NET Forms
Adding and Configuring ASP.NET Form Controls
Required Elements for the Contact Us Page
Adding Controls to the Contact Us Page
Configuring the Topics DropDownList Control
Processing ASP.NET Forms
The AutoPostBack Property
The Button Control
The IsPostBack Property
Displaying a Form Confirmation
Placing the Form into a Panel
Adding a Confirmation Message
Adding Server-Side Code
Checkpoint
Chapter 16 Adding Form Field Validation Using ASP.NET
The Necessity of Form Validation
ASP.NET Validation Controls
RequiredFieldValidator Control
RangeValidator
RegularExpressionValidator Control
CompareValidator Control
CustomValidator Control
ValidationSummary Control
Common Validation Control Properties
The Text Property
The Display Property
The ErrorMessage Property
The ControlToValidate Property
The EnableClientScript Property
The SetFocusOnError Property
The ValidationGroup Property
Adding and Configuring ASP.NET Validation Controls
Checkpoint
Part VIStyling Web Forms in Visual Web Developer 2008
Chapter 17 Creating and Managing CSS Styles
An Introduction to CSS
Basic CSS Rules
External Style Sheets
Embedded Style Sheets
Inline CSS Styles
Exploring CSS Classes and IDs
CSS Classes
CSS IDs
Using the Style Builder Dialog to Create Styles
Creating a Simple Style
Creating a New CSS Class
Using the Style Application Toolbar
Using the Style Application Toolbar to Apply Formatting
Applying Formatting to Existing Styles
Managing CSS Styles
The Manage Styles Pane
Using the Manage Styles Pane to Add New Styles
Using the Manage Styles Pane to Modify Styles
Checkpoint
Chapter 18 Applying CSS to Web Forms
Using the Apply Styles Pane
Applying a Style
Removing a Previously Applied CSS Class, CSS ID, or Inline Style
Using the CSS Properties Pane
Examining CSS Styles
Applying CSS Styles
Checkpoint
Chapter 19 Using ASP.NET Themes and Skins
Introduction to ASP.NET Themes
Makeup of a Theme
Global Themes and Page Themes
Skin Files
Creating a Theme
Creating the Folder Structure
Creating a Skin File
Generating Formatting Code for Controls
Transferring Formatting Code to the Skin File
Applying a Theme
Default Skins and Named Skins
Using a Theme with CSS Files
Checkpoint
Part VIIData Access with ASP.NET
Chapter 20 ASP.NET Data Controls
Accessing Data in ASP.NET 3.5
ASP.NET Data Source Controls
SqlDataSource Control
AccessDataSource Control
LinqDataSource Control
ObjectDataSource Control
XmlDataSource Control
SiteMapDataSource Control
Configuring a Data Source Control
Other ASP.NET Data Controls
GridView Control
DataList Control
DetailsView Control
FormView Control
ListView Control
Repeater Control
DataPager Control
Checkpoint
Chapter 21 Displaying Data from a Database
Configuring the Data Source
Adding an AccessDataSource Control
Configuring the AccessDataSource Control
Ordering Data
Filtering Data
Using Data Controls to Display Data
Adding a GridView Control
Adding Paging and Sorting Features
Creating a Master/Detail View
Configuring the GridView Control
Adding a Data Source Control for the DetailsView
Adding and Configuring the DetailsView Control
Checkpoint
Chapter 22 Adding, Editing, and Deleting Records
Creating the Editing Interface
Adding and Configuring a GridView Control
Adding and Configuring a New Data Source
Adding and Configuring the FormView Control
Configuring the Functionality of the Editor
Adding New Records
Editing Records
Deleting Records
Modifying Templates
Modifying the InsertItemTemplate
Modifying the EmptyDataTemplate
Checkpoint
Part VIIISending Email with ASP.NET
Chapter 23 Configuring ASP.NET for Email
How ASP.NET Sends Mail
The System.Net.SmtpClient Class
The System.Net.MailMessage Class
Modifying the Configuration File for Email
Adding Email Configuration to the web.config File
Using the Web Site Administration Tool
Checkpoint
Chapter 24 Sending Form Results to Email
Adding Server-Side Code to Send Email
Reviewing the Contact Form
Adding the Code
Explaining the Code
Sending HTML Emails
Sending Emails with Attachments
Checkpoint
Part IXAjax and Web Services
Chapter 25 Creating and Testing an ASP.NET Web Service
An Explanation of ASP.NET Web Services
The Structure of a Web Service
The WSDL Document
Creating an ASP.NET Web Service
Invoking a Web Service Directly
Creating a Dataset for Use with a Web Service
Creating the Dataset
Connecting to the Database
Adding a Parameter
Using a Dataset with a Web Service
Testing the Web Service
Using a Web Service in a Web Form
Adding a Reference to the Web Service
Adding a Data Source for the DropDownList Control
Completing the Configuration of the Web Form
Checkpoint
Chapter 26 Adding Ajax Functionality
What Is Ajax?
Microsoft’s ASP.NET AJAX
Microsoft AJAX Library
Microsoft ASP.NET AJAX Extensions
Microsoft AJAX ASP.NET Control Toolkit
Adding Ajax Functionality to a Web Form
Targeting the .NET Framework 3.5
Adding a ScriptManager Control
Adding an UpdatePanel Control
Using the AJAX Library
Adding Controls to the Web Form
Creating the Client Library
Adding the Client Script to the ScriptManagerProxy
Checkpoint
Part XDebugging and Troubleshooting ASP.NET
Chapter 27 Debugging ASP.NET Applications
The Basics of Debugging
Enabling and Configuring Debugging for an ASP.NET Application
Enabling Debugging
Configuring Debugging
Debugging Server-Side Code
Setting a Breakpoint
Examining the State of an Application
IntelliSense
The Locals Window
The Watch Window
The Immediate Window
Debugging Client-Side Scripts
Using the Error List to Locate Application Errors
Checkpoint
Chapter 28 Handling Errors in an ASP.NET Application
Exceptions and the .NET Framework
Exception-Handling Blocks
Bubbling Exceptions
Implementing Structured Exception Handling
Modifying the btnSend_Click Method
Adding a Panel to Display Errors
Throwing Exceptions
Adding a Global Exception Handler
Using the <customErrors> Element
<error> Elements
Checkpoint
Chapter 29 ASP.NET Tracing and Other Troubleshooting Techniques
ASP.NET Tracing
Enabling Tracing
Analyzing Trace Output
Request Details
Trace Information
Control Tree
Session State
Application State
Request Cookies Collection
Response Cookies Collection
Headers Collection
Response Headers Collection
Form Collection
Querystring Collection
Server Variables
ASP.NET Health Monitoring
Configuring the Application for Health Monitoring
Viewing Health Monitoring Logs
Monitoring the Network with Fiddler
Checkpoint
Part XIDeploying ASP.NET Applications
Chapter 30 Publishing an ASP.NET Application
Using the Copy Web Site Tool
Connecting to a Remote Site
Copying Websites with the Copy Web Site Feature
Special Considerations for Membership Websites
Obtaining the Application Name from the Database
Editing the web.config File
Wrapping Up
Appendix Application Settings in Visual Web Developer