A First Look at ASP.NET 2.0




Dynamic Web page generation techniques have been around for many years, but ASP.NET took the world by storm when it was released in February 2002. The advent of a new page and postback architecture, server controls, and the whole .NET Framework made it easier to build Web sites and Web applications that performed better while reducing the amount of work required by the developer.


So, it comes as no surprise to see a new version of .NET, and with it version 2.0 of ASP.NET starting to appear on the horizon. Sometime in 2004 we should see the final release of version 2.0 of the .NET Framework, together with new versions of Visual Studio and other tools. In the meantime, Microsoft are following their usual policy of involving developers as early in the process as possible, giving them the chance to provide feedback on the new product.


So, as the final release of version 2.0 is still some way off, why would you be interested in it now? The simple answer is, of course, that ó as a developer ó you need to keep abreast of what's going on in your industry. And more than that, being aware of what's coming in the future might well influence what you do today, in the overall design of your applications and the preparations and plans you are making for upcoming products and applications.


This book will help by introducing you to the new features that will be in version 2.0, and how they can benefit your Web site and Web application development. And it may be that you don't actually intend to install the early releases of version 2.0, but you just want to know more about what it offers. No problem - that's OK with us as well!


Important Note: Code Downloads, Versions and Release Schedules

Before you read any further, it's important that you understand what this book covers, and how it relates to the future and final releases of .NET version 2.0.


The current release of the .NET Frameworks is a "Technical Preview" or "Alpha" version, based on the second of three milestones specified during development of v 2.0. There will probably also be two or more "Beta" releases, starting early in 2004, and followed by a final release.


This book covers the "Technical Preview" release, but also discusses the plans for changes and extensions to the features in the Beta releases that will follow. What this effectively means is that the class interface listings and code samples you see here cannot be guaranteed to work in exactly the same way right through to the final release version.


Therefore, in order to make this book as useful as possible we are maintaining a Web site that details changes throughout the Beta cycle and up to final release of v 2.0. This site is at http://www.daveandal.net/da/dotnet2beta/. You'll also find news about release dates as it becomes available, more code examples, etc. You can also download the code for the book, and subsequent updates, from the same place.


What This Book Covers

This is not just a reference book, but instead is a feature-packed exploration of version 2.0 of ASP.NET. It covers the changes between ASP.NET 1.x and ASP.NET 2.0, describing how it makes it even easier to build efficient, attractive and interactive Web sites and Web applications using the new features in ASP.NET, while considerably reducing developer effort and code requirements.


The first chapter presents an overview of the new version, and also lays out the roadmap for the remainder of the book. The following chapters discuss how the common requirements of developers have been addressed, starting with the ubiquitous need to access data from your pages; and then progressing through to a detailed look at the new configuration and management features that version 2.0 provides.


Along with the final release of .NET 2.0 we will, of course, see a new version of Visual Studio.NET and other tools. While we do include some details of the new Visual Studio .NET, this is not an area that the book concentrates on. Many developers will be writing ASP.NET pages using other tools (including, we suspect, a text editor) while Visual Studio .NET is still under development.


What You Need To Use This Book

The main thing you need to use this book is one of the "Alpha" or "Beta" releases of version 2.0 of the .NET Framework release. The first "Technical Preview" or "Alpha" release is due late in 2003, and the book is based on this version.


Other than that, you'll need something to transfer your creative efforts into ASP.NET files on disk. We still prefer a text editor, though early experiments with the new version of Visual Studio .NET suggest that Windows NotePad will soon be seeing the light of day a lot less often in the future. Once it is available, in Beta or release version, we strongly recommend you try it out. However, it doesn't really matter which tool or editor you use as long as it can generate text files with the .aspx file extension.


Finally, you'll need to be prepared to change the way you think about building code for your Web pages, as in many cases you don't actually have to write any code at all in version 2.0. See Chapter 1 for more details, and get ready to be more productive!



Chapter 1 - An Introduction to ASP.NET 2.0

          What's Wrong with ASP.NET 1.x?

          New Features

          Templates for a consistent look and feel

          Styles for Controls

          Securing your Site

          Personalizing your Site

          Creating Portals

          Setting Up and Managing your site

          Using Images on your Site

          Using Data on your Site

          Adding Mobility Support

          Compilation and Deployment

          Development Tools



Chapter 2 - Tools and Architecture

          Visual Studio .NET

          Project-less Development

          The Solution Explorer

          The Toolbox

          The Design Window

          The Data Explorer

          Visual Inheritance

          Built-in Administration

          Code Separation

          Dynamic Compilation

          New Folders for Dynamic Compilation

          Using the Code folder in Visual Studio .NET

          Folder Hierarchy

          Pre-compilation of applications

          In-Place Pre-Compilation

          Pre-compilation for deployment without source

          Pre-compilation for deployment with source

          Compilation API

          Compilation Summary



Chapter 3 - Data Source Controls and Data Binding

          Code-Free Data Binding

          Displaying Data with a Data Source Control

          Adding Row Sorting Capabilities

          Adding Row Paging Capabilities

          Built-in Small-screen and Mobile Device Support

          Linking Page Controls and Data Source Control Parameters

          Editing Data with a GridView and Data Source Control

          The DetailsView Control

          Data Source Controls

          Types of Data Source Controls

          The SqlDataSource Control

          The AccessDataSource Control

          The XmlDataSource Control

          The DataSetDataSource Control

          The ObjectDataSource Control

          Possible Forthcoming Data Source Controls



Chapter 4 - The GridView and DetailsView Controls

          The GridView Control

          An Overview of the GridView Control

          Declaring a GridView Control

          Defining the Columns in a GridView Control

          Using a Mixture of Column Types

          The DetailsView Control

          Using a Stand-alone DetailsView Control

          Creating a Master-Detail Page with GridView and DetailsView Controls

          Inserting and Editing Rows with a DetailsView Control

          The DetailsView Control Interface

          The New and Simplified Data Binding Syntax

          The ASP.NET 1.0 Syntax for Data Binding

          Simplified ASP.NET 2.0 Syntax for Non-hierarchical Data Binding

          Simplified ASP.NET 2.0 Syntax for Hierarchical (XML) Data Binding

          Summary of the Simplified Data Binding Syntax

          Building Data-bound Pages with Visual Studio .NET



Chapter 5 - Master Pages and Site Navigation

          Master Pages in Detail

          Creating Master Pages

          Using a Master Page

          Default Content

          Nested Master Pages

          Master Page Configuration

          Device Specific Master Pages

          Event Ordering

          Accessing the Master Page


          Site Maps

          Site Map Providers

          Site Map Configuration File

          Using a SiteMap File

          Site Maps in Depth

          Showing a Navigation Path

          SiteMapPath Events

          SiteMap Nodes

          Accessing the SiteMap at Run Time



Chapter 6 - Security


          Membership Providers

          Setting up Membership

          Creating new Users

          Vaildating User Credentials

          Getting a user we created


          Updating the Userís Properties

          Deleting a User

          Security Server Controls

          Login Control <asp:Login runat="server">

          Login Status Control <asp:LoginStatus runat="server" />

          Login View Control <asp:LoginView runat="server" />

          Password Recovery Control <asp:PasswordRecovery runat="server" />

          Role Manager

          Setting up Role Manager

          Role Manager Configuration

          Creating Roles

          Adding Users to Role

          Returning roles the user belongs to

          Check if the user is in a role

          Removing users from roles

          Deleting a role

          Role Caching

          Cookieless Forms Authentication

          Enabling Cookieless Forms Authentication

          Web-based Administration Tool

          The Home Page

          The Security Page

          Security Management

          Other Pages



Chapter 7 - Personalization and Themes

          Storing and Retrieving User Personalization Data

          Configuring Personalization

          Accessing other userís Personalization Data

          Setting up the Databases for Personalization

          Data Access Optimizations

          Membership and Personalization

          Anonymous Identification

          Anonymous Personalization

          Migrating from Anonymous to Authenticated Users

          Provider Design Pattern


          Implementation of the IProvider interface

          Implementation of the specific feature interface

          Writing a Personalization Provider


          Themes and Skins

          Global Themes

          Creating Themes

          Setting a Page Theme

          Using Personalization for Themes

          Collections of Controls

          Disabling Themes

          Adding Themes to a Site

          Enabling Themes in Custom Controls



Chapter 8 - Web Parts and the Portal Framework

          The ASP.NET 2.0 Portal Framework

          The Goals of the Portal Framework

          About the Web Parts Framework

          A Simple Web Parts Example Page

          The Page in Outline

          The "Events" Zone Declaration

          The "Corporate Information" Zone Declaration

          The "EditorZone" Declaration

          The "CatalogZone" Declaration

          The "Controls" Zone Declaration

          Changing the WebPartDisplayMode

          Working with Web Parts in Code

          The WebPartManager Class

          The WebPartZone Class

          The WebPart Class

          Web Parts and Visual Studio .NET (Venus)



Chapter 9 - Pages, Posting and Validation

          Cross-Page Posting

          Posting to Another Page

          Accessing the Previous Page

          Transferring to Another Page in Code

          Detecting Cross Page Posting

          Page Lifecycle


          The ValidationGroup Property


          URL Mapping

          Client-side Script Features

          Form Focus

          Client Click Events

          Registering Script Blocks

          Client Call Backs

          Changes to Page directives

          The Page Directive

          The Master Directive

          The Control Directive

          The PreviousPage Directive

          The Image Directive

          Page and Control Lifecycle



Chapter 10 - Mobile Device Support

          Programming for Different Types of Device

          The Microsoft Mobile Internet Toolkit

          The Unified Control and Adapter Architecture

          Browser Definitions

          The BrowserCapabilities Class

          Page Design and Device Support

          Device Filters

          Controls and Attributes Specific to Mobile Devices

          The System.Web.UI.WebControls.Pager Control

          The PhoneLink Control

          The SoftKeyLabel Attribute

          Mobile Browser Emulators



Chapter 11 - Caching

          Enabling Database Cache Invalidation

          Enabling a Database for SQL Cache Invalidation

          Enabling a Table for SQL Cache Invalidation

          Listing Tables Enabled for SQL Cache Invalidation

          Invalidating the ASP.NET Cache


          Invalidating Output Cached Pages

          The SqlCacheDependency Class

          Creating SQL Server 7 and 2000 Dependencies

          Creating SQL Server Yukon Dependencies




Chapter 12 - Control Enhancements

          Summary of the New Controls in ASP.NET 2.0

          New Controls Summarized by Type

          The New Form and Page Based Controls in ASP.NET 2.0

          The BulletedList Control

          The FileUpload Control

          The HiddenField Control

          The Table Control in More Detail

          The DynamicImage Control

          The MultiView and View Controls

          The ImageMap Control

          Changes to the Existing ASP.NET Controls

          Changes to the Button, LinkButton and ImageButton Controls

          Changes to the Hyperlink Control

          Changes to the Image Control

          Changes to the Label Control

          Changes to the ListItem Control

          Changes to the Literal Control

          Changes to the Panel Control

          Changes To The BannerAd Control

          Site and Page Counters

          Using Site Counters

          Configuring Site and Page Counters

          Web Resources



Chapter 13 - Configuration and Administration

          Application Configuration File

          Changed Sections

          New Sections

          State Management

          Control State

          Page State Persistence

          Session State Plugability

          Management API

          IIS Integration

          Management Classes



©2003 - Stonebroom Limited, England