
- •Contents
- •Introduction
- •Acknowledgments
- •The Goals of ASP.NET 2.0
- •Developer productivity
- •Administration and management
- •Performance and scalability
- •Device-specific code generation
- •Additional New Features of ASP.NET 2.0
- •New developer infrastructures
- •New compilation system
- •Additions to the page framework
- •New objects for accessing data
- •New server controls
- •A New IDE for Building ASP.NET 2.0 Pages
- •The Document Window
- •Views in the Document Window
- •The tag navigator
- •Page tabs
- •Code change status notifications
- •Error notifications and assistance
- •The Toolbox
- •The Solution Explorer
- •Lost Windows
- •Other Common Visual Studio Activities
- •Creating new projects
- •Making references to other objects
- •Using smart tags
- •Saving and importing Visual Studio settings
- •Application Location Options
- •Built-in Web server
- •Web site requiring FrontPage Extensions
- •The ASP.NET Page Structure Options
- •Inline coding
- •New code-behind model
- •New Page Directives
- •New attributes
- •New directives
- •New Page Events
- •Cross-Page Posting
- •New Application Folders
- •\Code folder
- •\Themes folder
- •\Resources folder
- •Compilation
- •The New Data Source Controls
- •The SqlDataSource and GridView Controls
- •Reading data
- •Applying paging in the GridView
- •Sorting rows in the GridView control
- •Defining bound columns in the GridView control
- •Enabling the editing of rows in the GridView control
- •Deleting data from the GridView
- •Dealing with other column types in the GridView
- •Selecting which fields to display in the DetailsView control
- •Using the GridView and DetailsView together
- •Updating, inserting, and deleting rows
- •XmlDataSource Control
- •ObjectDataSource Control
- •SiteMapDataSource Control
- •DataSetDataSource Control
- •Visual Studio 2005
- •Connection Strings
- •Site Maps
- •The PathSeparator property
- •The PathDirection property
- •The ParentLevelsDisplayed property
- •The ShowToolTips property
- •Examining the parts of the TreeView control
- •Binding the TreeView control to an XML file
- •Selecting multiple options in a TreeView
- •Specifying custom icons in the TreeView control
- •Specifying lines used to connect nodes
- •Working with the TreeView control programmatically
- •Applying different styles to the Menu control
- •Menu Events
- •Binding the Menu control to an XML file
- •SiteMap Data Provider
- •SiteMapViewType
- •StartingNodeType
- •SiteMap API
- •Why Do You Need Master Pages?
- •The Basics of Master Pages
- •Coding a Master Page
- •Coding a Content Page
- •Mixing page types and languages
- •Specifying which master page to use
- •Working with the page title
- •Working with controls and properties from the master page
- •Nesting Master Pages
- •Container-Specific Master Pages
- •Event Ordering
- •Caching with Master Pages
- •Using ASP.NET 2.0 Packaged Themes
- •Applying a theme to a single ASP.NET page
- •Applying a theme to an entire application
- •Applying a theme to all applications on a server
- •Removing themes from server controls
- •Removing themes from Web pages
- •Removing themes from applications
- •Creating Your Own Themes
- •Creating the proper folder structure
- •Creating a skin
- •Including CSS files in your themes
- •Having your themes include images
- •Defining Multiple Skin Options
- •Programmatically Working with Themes
- •Themes and Custom Controls
- •Authentication
- •Authorization
- •ASP.NET 2.0 Authentication
- •Setting up your Web site for membership
- •Adding users
- •Asking for credentials
- •Working with authenticated users
- •Showing the number of users online
- •Dealing with passwords
- •ASP.NET 2.0 Authorization
- •Using the LoginView server control
- •Setting up your Web site for role management
- •Adding and retrieving application roles
- •Deleting roles
- •Adding users to roles
- •Getting all the users of a particular role
- •Getting all the roles of a particular user
- •Removing users from roles
- •Checking users in roles
- •Using the Web Site Administration Tool
- •The Personalization Model
- •Adding a simple personalization property
- •Using personalization properties
- •Adding a group of personalization properties
- •Using grouped personalization properties
- •Defining types for personalization properties
- •Using custom types
- •Providing default values
- •Making personalization properties read-only
- •Anonymous Personalization
- •Enabling anonymous identification of the end user
- •Working with anonymous identification events
- •Anonymous options for personalization properties
- •Migrating Anonymous Users
- •Personalization Providers
- •Working with the Access personalization provider
- •Working with the SQL Server personalization provider
- •Using multiple providers
- •Building Dynamic and Modular Web Sites
- •Introducing the WebPartManager control
- •Working with zone layouts
- •Understanding the WebPartZone control
- •Explaining the WebPartPageMenu control
- •Modifying zones
- •Caching in ASP.NET 1.0/1.1
- •Output caching
- •Partial page caching
- •Data caching using the Cache object
- •Cache dependencies
- •ASP.NET 2.0 unseals the CacheDependency class
- •Enabling databases for SQL Server cache invalidation
- •Enabling tables for SQL Server cache invalidation
- •Looking at SQL Server
- •Looking at the tables that are enabled
- •Disabling a table for SQL Server cache invalidation
- •Disabling a database for SQL Server cache invalidation
- •Configuring your ASP.NET Application
- •Adding more than one table to a page
- •Attaching SQL Server cache dependencies to the Request object
- •Attaching SQL Server cache dependencies to the Cache object
- •Customizing the side navigation
- •Examining the AllowReturn attribute
- •Working with the StepType attribute
- •Adding a header to the Wizard control
- •Utilizing Wizard control events
- •Working with images from disk
- •Resizing images
- •Displaying images from streams
- •The MMC ASP.NET Snap-In
- •General
- •Custom Errors
- •Authorization
- •Authentication
- •Application
- •State Management
- •Advanced
- •ASP.NET Web Site Administration Tool
- •Home
- •Security
- •Profile
- •Application
- •Provider
- •Managing the Site Counter System
- •Generics
- •Iterators
- •Anonymous Methods
- •Operator Overloading
- •Visual Basic XML Documentation
- •New Visual Basic Keywords
- •Continue
- •Using
- •Global
- •Index

Application and Page Frameworks
page. In this case, the value assigned is Default.aspx.vb or Default.aspx.cs. The second attribute needed is the ClassName attribute. This attribute was available in previous versions of ASP.NET, but was little used. This attribute specifies the name of the class that is bound to the page when the page is compiled. The directives are simple enough in ASP.NET 2.0. Take a look at the code-behind page from Listing 3-5.
The code-behind page is rather simple in appearance now using the partial class capabilities that .NET 2.0 provides. You can see that the class created in the code-behind file uses partial classes, employing the new Partial keyword in Visual Basic 8.0 and the partial keyword from C#. This enables you to simply place the methods that you need in your page class. In this case, you have a button-click event and nothing else.
New Page Directives
ASP.NET directives are something that is a part of every ASP.NET page. You can control the behavior of your ASP.NET pages by using these directives. Here’s an example of the Page directive:
<%@ Page Language=”VB” AutoEventWireup=”false” CompileWith=”Default.aspx.vb” ClassName=”Default_aspx” %>
New attributes
These page directives are commands for the compiler to use as the page is compiled. A large number of attributes have always been available to the Page directive itself, but with the introduction of ASP.NET 2.0, some additional attributes are available. These six important new attributes are explained in the following table.
New Attribute |
Description |
|
|
CompileWith |
Takes a String value which points to the code-behind |
|
file used. |
EnablePersonalization |
Boolean value that specifies whether the new ASP.NET |
|
2.0 personalization features are used with the page. |
LinePragmas |
Boolean value that specifies whether line pragmas are |
|
used with the resulting assembly. |
Master |
Takes a String value that points to the location of the |
|
master page used with the page. This attribute is used |
|
with content pages. |
PersonalizationProvider |
Takes a String value that specifies the name of the per- |
|
sonalization provider used in applying personalization |
|
to the page. |
Theme |
String value that specifies the theme used with the page. |
|
|
51

Chapter 3
New directives
In addition to the new attributes used with the Page directive, two new directives can be also be used for the pages you create. These new directives include the following:
Master: This directive is used in the creation of master pages — the main templates used by any subpages within your applications. Master pages are explained in Chapter 6.
PreviousPage: This directive is used to specify the page from which any cross-postings originate. Cross-posting ASP.NET pages are explained later in this chapter.
The Master page directive is similar to the Page directive, but you specify properties of the templated page that you will be using in conjunction with any number of content pages in your site. Any content pages (built using the Page directive) you might have can then inherit from the master page all the master content (defined in the master page using the Master directive). Although they are similar, the Master directive has fewer attributes available to it than the Page directive. The available attributes for the Master directive include:
|
AutoEventWireUp |
|
Explicit |
|
ClassName |
|
Inherits |
|
CodeBehind |
|
Language |
|
CompilerOptions |
|
LinePragmas |
|
CompileWith |
|
Master |
|
Debug |
|
Src |
|
Description |
|
Strict |
|
EnablePersonalization |
|
Theme |
EnableViewState
These attributes need not be defined because they are the same as those for the Page directive, except that they apply to the master page that is used in templating your pages.
The PreviousPage directive is a new directive that works with the new cross-page posting capability that ASP.NET 2.0 provides. This simple directive contains only two possible attributes: TypeName and VirtualPath. The following table describes these two new attributes.
New Attribute |
Description |
|
|
TypeName |
Specifies the strong type used in the previous page. |
VirtualPath |
String value specifying the relative path of the page that is |
|
cross-posting to the working page. |
|
|
52