You are previewing Introducing Microsoft® ASP.NET 2.0.
O'Reilly logo
Introducing Microsoft® ASP.NET 2.0

Book Description

Get your first official look at the features and infrastructure changes in Microsoft® ASP.NET 2.0—and get a head start on evaluating, planning for, and exploiting its new capabilities in your Web development projects.

Table of Contents

  1. Copyright
    1. Dedication
  2. Acknowledgments
  3. Introduction
    1. What This Book Covers
    2. System Requirements
    3. Code Samples
    4. Support
    5. Contact Information
  4. I. ASP.NET Essentials
    1. 1. Creating an ASP.NET 2.0 Application
      1. Getting Started with Visual Studio 2005
        1. Drawbacks of Visual Studio .NET 2003
        2. Highlights of Visual Studio 2005
      2. Creating a Sample Web Site
        1. Designing Web Forms
        2. Adding Code to Web Forms
        3. The Local Web Server
        4. Special Folders in ASP.NET 2.0 Applications
      3. The Code-Beside Model
        1. Evolving from Code-Behind
        2. Compile-on-Demand for All Resources
          1. Code-Beside vs. Code-Behind
          2. Partial Classes
        3. Sharing Source Components
          1. The Code Subdirectory
          2. Building a Sample Shared Class
      4. The Page Object Model
        1. What’s New in the Page Class
          1. The @Page Directive
          2. Properties of the Page Class
          3. Methods of the Page Class
          4. Events of the Page Class
          5. The Page Life Cycle
        2. Programming the Page
          1. The HtmlHead Control
          2. Cross-Page Postbacks
          3. Paging the Page
        3. The Page Scripting Object Model
          1. Script Callbacks
          2. Setting the Focus
      5. Overview of Server Controls
        1. New Control Features
          1. Adaptive Rendering
          2. Control State
        2. New Core Controls
          1. The Panel Control
          2. The MultiView Control
          3. The Wizard Control
          4. The BulletedList Control
          5. The DynamicImage Control
          6. The FileUpload Control
      6. Summary
    2. 2. Working with Master Pages
      1. The Rationale Behind Master Pages
        1. User Controls in ASP.NET 1.x
          1. What’s Good About User Controls
          2. What’s Bad About User Controls
        2. Include Files in Classic ASP
          1. What’s Good About Include Files
          2. What’s Bad About Include Files
        3. Outline of a Better Approach
      2. What Are Master Pages?
        1. Writing a Master Page
          1. The @Master Directive
          2. The ContentPlaceHolder Container Control
          3. Specifying Default Content
        2. Writing a Content Page
          1. The Content Control
          2. Attaching Pages to a Master
          3. Device-Specific Masters
      3. Underpinnings of Master Pages
        1. Merging Master and Content Pages
          1. The MasterPage Class
          2. Importing Compiled Templates
        2. Nested Masters
          1. Designing Nested Masters
          2. Building an Example
        3. Event Handling
      4. A Realistic Example
        1. Master Pages and Visual Inheritance
        2. Layout of the Pages
        3. Contents of the Pages
        4. Programming the Master
          1. Exposing Master Properties
          2. Invoking Properties on the Master
          3. Changing the Master Page
      5. Summary
    3. 3. Working with Web Parts
      1. Building Pages with Web Parts
        1. What Are Web Parts, Anyway?
          1. Content of a Web Part
          2. Layout of a Web Part
        2. Introducing the Web Parts Framework
          1. Web Part Zones
          2. The WebPartManager Class
          3. The WebPart Class
        3. A Sample Web Part Component
          1. The BookFinder Web Part
          2. Styling the Web Zone
          3. Changing the Zones Layout
          4. Persisting Layout Changes
      2. Editing and Listing Web Parts
        1. Creating an Editor Zone
          1. The Edit Mode
          2. The Editor Part Components
        2. Adding Web Parts Dynamically
          1. The Catalog Zone
          2. The Catalog Part Components
      3. Connecting to Other Web Parts
        1. The Connection Model
          1. Enabling Web Parts Connectivity
          2. Connection Points and Interfaces
        2. Building a Master/Detail Schema
          1. Provider Web Part Components
          2. Consumer Web Part Components
          3. Putting It All Together
      4. Summary
    4. 4. Personalization: User Profiles and Themes
      1. Managing User Profiles
        1. Creating the User Profile
          1. Using Scalar Properties
          2. The User Profile Class Representation
          3. Using Collection Types
          4. Using Custom Types
          5. Grouping Properties
        2. Personalization Providers
          1. Configuring Personalization Providers
          2. The Access Personalization Provider
          3. The SQL Server Personalization Provider
          4. Custom Personalization Providers
        3. Interacting with the Page
          1. Creating the Personalization Database
          2. Anonymous Personalization
          3. Accessing Personalization Properties
          4. Personalization Events
      2. Using Themes
        1. What Are Themes?
          1. Structure of a Theme
          2. Creating Themes
        2. Working with Themes
          1. The SmokeAndGlass Built-In Theme
          2. Theming Your Pages and Controls
          3. Loading Themes Dynamically
      3. Summary
  5. II. Data Access
    1. 5. What’s New in Data Access
      1. Data-Binding Syntax Enhancements
        1. The DataBinder Class
          1. The Eval Method
          2. A More Compact Eval
          3. Getting the Default Data Item
        2. The XPathBinder Class
          1. The XPathBinder.Eval Method
          2. Enumerating the Node Set
      2. .NET Data Provider Enhancements
        1. Connection String Storage
          1. The <connectionStrings> Section
          2. Retrieving Connection Strings Programmatically
          3. Declarative Binding of Connection Strings
          4. Protecting Configuration Data
        2. The Provider Factory Model
          1. Instantiating Providers Programmatically
          2. Enumerating Installed Data Providers
        3. Batch Operations
          1. The UpdateBatchSize Property
          2. Profiling Batch Calls
          3. Batch Update–Related Events and Errors
      3. SQL Server Provider Enhancements
        1. Asynchronous Commands
          1. The .NET Asynchronous Pattern
          2. Executing a Command Asynchronously
        2. Bulk Copy Operations
          1. The SqlBulkCopy Class
          2. Copying Data from Table to Table
          3. Bulk Copy and the bcp Utility
          4. Tracking a Bulk Copy Operation
        3. SQL Server 2005–Specific Enhancements
          1. A Unified Model for Large Data Types
          2. Support for CLR Types
          3. Support for XML as a Native Type
          4. SQL Notifications and Dependencies
          5. Multiple Active Resultsets
      4. ADO.NET Class Enhancements
        1. DataTable and DataSet Readers
          1. The DataTableReader Class
          2. Filling a Table Using a Data Reader
        2. Serializing a DataTable to XML
          1. The WriteXml Method
          2. The ReadXml Method
          3. The XML Serializer
          4. The .NET Remoting Format
        3. Managing Views of Data
          1. Creating a Table from a View
          2. Selecting Distinct Rows
      5. Summary
    2. 6. The Data Source Object Model
      1. The Rationale of Data Source Components
        1. Codeless Data Binding
          1. An Inspiring Best Practice
          2. The Equivalent ASP.NET 1.x Code
          3. Integration with the Existing ASP.NET Framework
        2. A Consistent Model for Heterogeneous Data Sources
          1. Defining a Standard Set of Data Operations
          2. Binding Data Source Components to Controls
        3. A Richer Design-Time Experience
      2. Data Source Control Internals
        1. The IDataSource Interface
          1. Members of the Interface
          2. Data Source Views
        2. Tabular Data Source Controls
          1. The SqlDataSource Class
          2. The AccessDataSource Class
          3. The DataSetDataSource Class
          4. The ObjectDataSource Class
        3. Hierarchical Data Source Controls
          1. The SiteMapDataSource Class
          2. The XmlDataSource Class
      3. Using the SqlDataSource Control
        1. Connecting to Data Source Controls
        2. Data Source Parameters
          1. Parameter Types
          2. Binding Formal Parameters and Actual Values
        3. Caching Behavior
          1. Enabling Automatic Caching
          2. SQL Server Cache Dependency
      4. Summary
    3. 7. Data-Bound Controls
      1. Hierarchy of Data-Bound Controls
        1. The DataBoundControl Base Class
          1. Properties of the DataBoundControl Class
          2. Methods of the DataBoundControl Class
        2. Simple Data-Bound Controls
          1. The AdRotator Control
          2. The BulletedList Control
          3. Other List Controls
        3. Composite Data-Bound Controls
          1. Basic Behavior of Composite Controls
          2. The CompositeDataBoundControl Class
          3. Examples of Composite Data-Bound Controls
        4. Hierarchical Data-Bound Controls
          1. Building a Tree-Based Data View
          2. The Menu Control
      2. The GridView Control
        1. The GridView Object Model
          1. Properties of the GridView
          2. Events of the GridView Control
        2. The GridView Control in Action
          1. Simple Data Binding
          2. Working with an Empty Data Source
          3. Adaptive Rendering
        3. Displaying Data
          1. Configuring Columns
          2. Templated Fields
          3. Sorting Data
          4. Paging Data
        4. Editing Data
          1. In-Place Editing and Updates
          2. Deleting Displayed Records
          3. Inserting New Records
      3. The DetailsView Control
        1. The DetailsView Object Model
          1. Properties of the DetailsView
          2. Events of the DetailsView
        2. The DetailsView Control in Action
          1. Editing the Current Record
          2. Inserting a New Record
          3. Controlling the Displayed Fields
        3. Creating Master/Detail Views
          1. Selecting a Record in the GridView
          2. Drill Down into the Selected Record
      4. The FormView Control
        1. The FormView Object Model
          1. Members of the FormView Control
          2. Supported Templates
        2. The FormView in Action
          1. Displaying Data
          2. Editing Data
      5. Summary
  6. III. Application Services
    1. 8. Rich Controls and Services
      1. Creating Web Wizards
        1. An Overview of the Wizard Control
          1. Structure of a Wizard
          2. Wizard Styles and Templates
          3. The Wizard’s Programming Interface
        2. Adding Steps to a Wizard
          1. Types of Wizard Steps
          2. Creating an Input Step
        3. Navigating Through the Wizard
          1. Filtering Page Navigation with Events
          2. Canceling Events
          3. Finalizing the Wizard
      2. Generating Dynamic Images
        1. The DynamicImage Control
          1. Architecture of Dynamic Image Controls
          2. The Programming Interface of Dynamic Image Controls
        2. Displaying Images in ASP.NET Pages
          1. Images from Files
          2. Images from Databases
          3. Dynamically Generated Images
          4. Using a Custom Image-Generation Service
      3. Advanced Site Functionality
        1. Site Structure and Navigation
          1. Defining the Site Map
          2. Accessing Site Map Information
          3. Binding Site Map Information to Controls
          4. The SiteMapPath Control
        2. Site Counters
          1. Counting Clicks on Server Controls
          2. Tracking Page Views
          3. Accessing Counters Programmatically
          4. Site Counter Providers
      4. Summary
    2. 9. State Management
      1. The Control State
        1. Control State vs. View State
          1. Drawbacks of the View State
          2. When to Use Control State
        2. Programming the Control State
          1. Maintaining State for a Control
          2. Persisting the Control State
      2. Extending the Session State Mechanism
        1. The Default Session State Module
          1. Acquiring the State for the Request
          2. Releasing the State for the Request
          3. Terminating the Request
        2. Customizing the Session State Module
          1. Replacing the Session Data Store
          2. Replacing the Session State Item
          3. Replacing the Session Data Dictionary
          4. Generating a Custom Session ID
        3. Writing a Custom Session State Module
          1. Initialization of the Module
          2. Acquiring Session State
          3. Releasing Session State
      3. The ASP.NET Cache Object
        1. The Cache Dependency Functionality
          1. Tracking Changes in Files and Directories
          2. Tracking Changes in Cached Items
          3. What Cache Dependencies Cannot Do in ASP.NET 1.x
        2. Designing a Custom Dependency
          1. Extensions to the CacheDependency Base Class
          2. Getting Change Notifications
          3. The AggregateCacheDependency Class
        3. A Web Service–Based Cache Dependency
          1. Designing the WeatherCacheDependency Class
          2. Implementing the Dependency
          3. Testing the Web Service Dependency
        4. SQL Server Cache Dependency
          1. Enabling Databases to Support Notifications
          2. Creating SQL Server Dependencies
          3. Overview of the Implementation
          4. Cache Dependencies in SQL Server 2005
      4. Summary
    3. 10. ASP.NET Security
      1. Using Forms Authentication
        1. Forms Authentication Control Flow
        2. Cookie-Based Forms Authentication in ASP.NET 1.x
        3. A Cookieless Approach in ASP.NET 2.0
        4. Configuring Forms Authentication
          1. The Cookieless Attribute
          2. Setting the Default Return URL
          3. Setting the Cookie’s Domain
        5. The FormsAuthentication Class
          1. Properties of the FormsAuthentication Class
          2. Methods of the FormsAuthentication Class
          3. Setting Up a Forms Authentication Layer
      2. Managing Membership and Roles
        1. The Membership Class
          1. The Programming Interface of the Membership Class
          2. Setting Up Membership Support
          3. Managing Users and Passwords
        2. The Membership Provider
          1. The ProviderBase Class
          2. The MembershipProvider Class
          3. Built-In Providers
          4. Configuring a Membership Provider
        3. Managing Roles
          1. The Role Management API
          2. The Roles Class
          3. The Role Provider
      3. Security-Related Controls
        1. The Login Control
          1. Setting Up the Login Control
          2. The Programming Interface of the Control
          3. Events of the Control
        2. The LoginName Control
        3. The LoginStatus Control
          1. Setting Up the LoginStatus Control
          2. The Programming Interface of the Control
        4. The LoginView Control
          1. The Programming Interface of the Control
          2. Creating a Login Template
          3. Creating Role-Based Templates
        5. The PasswordRecovery Control
          1. Configuring the Environment
          2. Retrieving a Password
        6. The ChangePassword Control
        7. The CreateUserWizard Control337
      4. Summary
  7. IV. Advanced Topics
    1. 11. The ASP.NET Runtime Environment
      1. Installing ASP.NET 2.0
        1. Side-by-Side Backward Compatibility
        2. Remapping Applications to ASP.NET 1.1
      2. The ASP.NET Underpinnings
        1. The IIS 5.x Process Model
        2. The IIS 6.0 Process Model
          1. The WebHost Application Management System
          2. The WebHost Process Manager
          3. Protocol Handlers
          4. Walking Through an ASP.NET Request
        3. ASP.NET Runtime Components
          1. Tools and Executables
          2. Built-In HTTP Handlers
          3. New HTTP Modules
        4. Page Output Caching
          1. The @OutputCache Directive
          2. The SqlDependency Attribute
          3. Disk Output Cache
          4. Post-Cache Substitution
      3. The Structure of ASP.NET 2.0 Pages
        1. A Sample Page
        2. A Quick Look at the HTML Source Code
      4. The Compilation Model
        1. Dynamic Compilation
          1. The Code Folder
          2. The Resources Folder
          3. The Themes Folder
          4. Compilation Settings and Life Cycle
        2. Site Precompilation
          1. In-Place Precompilation
          2. Precompilation for Deployment
      5. Summary
    2. 12. ASP.NET Configuration and Instrumentation
      1. Changes to the Configuration API
        1. Section-Specific Classes
        2. Reading Configuration Settings
        3. Writing Configuration Settings
        4. The ASP.NET Administrative Tool
      2. Changes to the Configuration Schema
        1. Changed Configuration Sections
        2. New Configuration Sections
      3. The Health Monitoring API
        1. Customizable Event-Level Analysis
        2. Automated Notification of Problems
      4. Summary
  8. About the Author