- •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
Administration and Management
Figure 14-23
Managing the Site Counter System
Another outstanding management feature is ASP.NET’s capability to monitor the views and clicks occurring in an application. Not only does the new site counter system count the views and clicks that occur as end users work through your Web application, it also generates reports in the browser with the site counter results.
To see an example of the new site counter system, begin by working with the ASP.NET Web Site Administration Tool. Open WAT and click the Configure Counter Settings link on the Application tab. You see a page dealing with counters, as shown in Figure 14-24.
407
Chapter 14
Figure 14-24
On this screen, make sure that the Enable Counter For Controls check box is checked. Then, in the text box labeled Specify How Many Rows Per Day of Site Statistics Will Be Written to the Database, keep the default of 1. One row in the database is used to store the counts. For the rest of the options, make sure the Track Application Name and Track Page URL check boxes are checked. Give your created site counter configuration a name and associate it to a counter group. As you can see in Figure 14-24, I gave the counter the name BannerAds and the counter group the name PageCounters. Finally, save your configuration by clicking the Save button in the lower-right corner of the dialog.
This operation has changed your web.config file. The results are shown in Listing 14-1.
Listing 14-1: Enabling the web.config for the site counter system
<?xml version=”1.0”?> <configuration>
<system.web>
<siteCounters defaultProvider=”AspNetAccessProvider” enabled=”true” rowsPerDay=”1”>
<pageCounters enabled=”true” trackApplicationName=”true” trackPageUrl=”true” counterName=”BannerAds”
408
Administration and Management
counterGroup=”PageCounters” /> </siteCounters>
</system.web>
</configuration>
Remember that although it is possible to work with tools such as WAT to build all this for you in the application’s configuration file, you can also place all the information in the web.config file yourself. The best approach is whatever is easier for you in the end.
Now that you have configured the web.config file to work with control clicks, learn how to monitor button clicks and views of an AdRotator server control. This is a common scenario because many Web sites sell advertising and charge their clients based on views, clicks, or both. Not only will the site counter system tally these items for you, but it also provides the GUI reports of what was tallied. Listing 14-2 shows an AdRotator control enabled to work with the site counter system.
Listing 14-2: A server control working with the site counter system
<%@ Page Language=”VB” %>
<html xmlns=”http://www.w3.org/1999/xhtml” > <head runat=”server”>
<title>AdRotator Page</title> </head>
<body>
<form id=”form1” runat=”server”>
<asp:AdRotator ID=”AdRotator1” Runat=”server” AdvertisementFile=”MyAds.xml” CountViews=”true” CountClicks=”true” />
<p>Lorem ipsum dolor sit
amet, consectetuer adipiscing elit. Duis vel justo. Aliquam adipiscing. In mattis volutpat urna. Donec adipiscing, nisl eget dictum egestas, felis nulla ornare ligula, ut bibendum pede augue eu augue. Sed vel risus nec urna pharetra imperdiet. Aenean semper. Sed ullamcorper auctor sapien. Suspendisse luctus. Ut ac nibh. Nam lorem. Aliquam dictum aliquam purus.</p>
</form>
</body>
</html>
This AdRotator server control isn’t much different from the AdRotator server control shown in Listing 13-7 in the last chapter — although this one has a couple of new attributes. To work with the site counter system provided by ASP.NET 2.0, you add the CountViews and the CountClicks attributes. In both cases, you set these attribute values to True. The CountViews attribute enables or disables the site counter system, which records each and every time that the image shown by the AdRotator control is actually viewed in the browser. The CountClicks attribute is always a lesser number because it enables or disables the site counter system that counts the number of times an end user clicks on the advertisement.
Now that both of these attributes have been set to True and the web.config file is configured properly, you can run the application and refresh the page a few times. Click the advertisement generated by the AdRotator control a few times to generate some results for the site counter system.
409
Chapter 14
Then, with the ASP.NET Web Site Administration Tool, return to the Application tab and click the Site Counter Reports link. This pulls up details on the PageCounter’s Details page. From this page, you can see the number of page views that have been counted by the system. From the drop-down list on the page, select AdRotator. This causes WAT to pull up details about the AdRotator server control, as shown in Figure 14-25.
Figure 14-25
On this page, you can see the date the views or clicks were recorded, the page the details came from, and the ID of the server control (in this case AdRotator1). It also shows the count event (Views or Clicks), the destination URL of the control, and finally the number recorded by the site counter system.
Summar y
This chapter showed you some of the new management tools that come with the latest release of ASP.NET. These new tools make the ever-increasing size of the web.config file more manageable because the tools take care of setting the appropriate values in the application’s configuration file.
410
Administration and Management
The ASP.NET snap-in to the Microsoft Management Console is a welcome addition for managing applications that are configured to work with IIS. The ASP.NET Web Site Administration Tool provides even more value to administrators and developers as it enables them to remotely manage settings.
Finally, you learned how to use the site counter system to create detailed reports on the clicks and views that your Web application produces.
411
Visual Basic 8.0 and C# 2.0
Language Enhancements
A lot has changed with the Whidbey release of .NET. Not only are there dramatic changes to ASP.NET (as I have shown you throughout this book), but considerable changes have been made to the IDE, Windows Forms, Visual Basic, C#, and more. This chapter focuses on the changes to Visual Basic and C# languages because these are the two languages most commonly used for ASP.NET development. Because of their heavy use in Web application development, it is vital to understand the capabilities of these languages and the direction they are taking.
Probably one of the greatest changes to Web application development in the Microsoft world is
.NET’s use of true object-oriented languages such as Visual Basic .NET and C# to build Web applications. You are no longer required to work with interpreted languages. Although they have only recently been introduced to the Web application world, these object-oriented languages are continuing to evolve, bringing new features to Web application development.
This last chapter focuses on the changes that have occurred to both Visual Basic and C# with this latest release of the .NET Framework. You can apply what you learn here directly to your ASP.NET 2.0 applications.
Over view of Changes
Both Visual Basic and C# have undergone changes with the release of the .NET Framework 2.0. Some of the changes have occurred in both languages, whereas other changes have occurred in only one.
