Team LiB
Previous Section Next Section

Chapter 1: ASP.NET 2.0 at a Glance

What's new in ASP.NET? What's changed in C# and VB .NET? In this chapter, I'll take you on a whirlwind tour of the new features to whet your appetite. The rest of the book will look at these features and how they're implemented in more detail.

What's New in ASP.NET 2.0?

The ASP.NET team lead by Scott Guthrie resolved to do a lot of things in the second version of ASP.NET to leave the competitors behind in the hard-fought e-business market. The team in Redmond defined some main goals:

The team has split the development into three logical units and set up an architecture stack, as depicted in Figure 1-1. At the base of this stack are the application services, which offer basic framework features. On top of this, the page functions implement page-specific functionalities. Last but not least, the developer gets a set of rich web controls built on these page functions. These controls are more specific to particular requirements than they have been up to now.

Click To expand
Figure 1-1: The ASP.NET architecture stack is made up of three logical units.

New Controls

The final release of ASP.NET 2.0 will include more than 40 (!) additional controls. All existing controls will, of course, remain to ensure backwards compatibility.

The Data Controls especially turn up with a lot of enhancements. For example, the "new DataGrid control," called GridView, now offers features like sorting, paging, selection, and editing of its content right out of the box. Compared to the DataGrid control, GridView requires no extra code thanks to a brand new Data Source Provider. Communication between database (or other sources) and the control is handled by this new data source model in a transparent way and includes both reading data from and writing data to the data source.

Another new Data Control is DetailsView. It displays only one record instead of a list. The output is usually a vertical listing of the data fields, but can be configured by a custom template.

Both of these controls can be used together (see Figure 1-2). In this example, the GridView control is used to display a list of the items of the Northwind Customer table. The currently selected item is shown in a DetailsView control below the list, which allows you either to edit or to delete the entry. Of course, you can add a new item this way, too. Did I mention that the whole example was developed without a single line of code?

Click To expand
Figure 1-2: Here are the new Data Controls as they appear in a real zero-code scenario.

You'll have real fun using the TreeView control, because it can display hierarchical data. In case you know the existing Internet Explorer Web Controls, it's important for me to mention that this control has nothing to do with the IE TreeView control in version 1.x, and it doesn't use the IE behavior, either. Because it supports the Data Source Provider concept explained earlier, you can bind several different source types to the TreeView control. This includes XML data, for example.

BulletedList is another control designed for data binding. It displays data in a highly configurable HTML list and includes support for hyperlinks and link buttons.

A number of other controls will help you with the output of dynamic pictures, the use of image maps, the upload of files (as web controls!), the rapid implementation of wizards, and much more.

Master Pages

In ASP.NET 1.0 and 1.1, there was no support for so-called Master Pages. Master Pages enable you to place parts of a page (such as header and footer sections) that are commonly used on many pages of a web site into a single file instead of repeating them in the code of every page. If you didn't want to set up a layout for each and every page, you had two choices: Place a User Control on each page, or use one of several published workarounds.

With ASP.NET 2.0, this process is going to be much easier. Master Pages are now one of the standard features (see Figure 1-3 for an example). This includes the support of several content placeholders. The use of Master Pages is quite simple, so you can now rely on the visual design support of the development environment.

Click To expand
Figure 1-3: Master Pages help to ensure a consistent design.

Site Navigation

Like Master Pages, the implementation of navigation is a necessity for any web application, and it doesn't matter if it's designed for the Internet, or an intranet or extranet. From now on, you can benefit from an integrated navigation structure, based on XML data, for example. Additional controls like positioning indicators (known as breadcrumbs) and a DHTML menu make it easy to offer a clearly arranged structure to the user.

Again, a provider does the job of feeding the navigation with data. This gives you the chance to use your own database instead of the integrated site map support. A provider in general acts as a bridge between a common framework functionality and a custom implementation, such as a custom data store. This new approach allows you to provide your own implementation wherever the default doesn't meet your needs, while still taking advantage of the overall model, and is also used in several other parts of version 2.0.

The web site in Figure 1-4 is based on the previous Master Page example and demonstrates the usage of a data-bound TreeView control and the SiteMapPath control to display the current position within the whole web site structure. And still the example contains no code!

Click To expand
Figure 1-4: Including TreeView navigation is really easy now.

User Management

How often did you develop a user management system? Did you ever try to combine Forms Authentication with individual roles? This is a lot to do, and it's really tricky, too. Again, the new version of ASP.NET provides numerous ways to relieve this problem.

ASP.NET version 2.0 contains a complete user management system out of the box. It comes with an extensive API; special controls for registration, login, and so on; and data providers that handle the data storage without any code from your side. This way you can set up a secured web site—again without have to write a single line of code!

For your convenience, the configuration of the user management system and the creation of the database are assisted by the wizard shown in Figure 1-5 as part of the new ASP.NET web administration feature. Here you can decide how the passwords are stored and whether users are allowed to reset their passwords after answering a question, which they define during registration. Furthermore, the tool enables you to manage the users and their roles (see Figure 1-6).

Click To expand
Figure 1-5: The Security Setup Wizard helps set up a secured web site.
Click To expand
Figure 1-6: You can now manage users and roles out of the box.


Personalization is another exciting topic, and ASP.NET version 2.0 comes up with a variety of solutions. It can be used with the integrated user management system as well as with anonymous users. The latter will be recognized by a cookie on a subsequent visit.

Personalization storage makes it possible to assign any information to a user account, save it to persistent storage, and automatically load it back in for the next session. This could be the user's time zone, the user's name, and other preferences—simply put, the type of information you want to be able to save in the web.config file and easily access, even with IntelliSense support. Yet complex data structures like a shopping cart with some product data can be persisted using XML serialization in the same way.

Another feature of personalization is based on pages and the so-called Web Parts, and it allows you to define one or more zones. In each of these zones, a user can arrange the information elements (known as Web Parts) using drag and drop. This means moving, deleting, or even changing the content. A zip code can be assigned to the Weather Web Part shown in Figure 1-7, and the local weather will be displayed as a result.

Click To expand
Figure 1-7: It's not that hot in L.A. today.

And the best part is, you don't even have to take care of data storage while using personalization, as the Data Provider does this job for you. All information will be stored in a SQL Server or Microsoft Access database, for example. Plug and play at its best!


Do you know the forums on This voluminous and comfortable system of forums was completely developed in ASP.NET. And members of the ASP.NET team offer you to download the entire source code for free. One of the features the code supports is the capability to adjust the design by various Themes similar to some trendy desktop applications like WinAmp. In the case of the forums application, Theme support is implemented manually by individually loading different designs.

With the new ASP.NET version, you can use functionalities like this with no additional effort other than defining the Theme itself. The standard installation already includes some sample Themes. Just activate them by a little entry in the configuration of your application. Figures 1-8 and 1-9 show exactly the same page but with different Themes. Of course, you can design your own Themes for your application or modify the existing ones to fit to your needs.

Click To expand
Figure 1-8: This Theme is called Basic Blue . . .
Click To expand
Figure 1-9: . . . and this one is called Smoke And Glass.

Other than design properties, the implementation of the Themes functionality includes CSS support and allows the integration of individual graphics. You can define which Theme or sub-Theme (called a Skin) will be used per application, per page, or per control in a very sophisticated way.

Mobile Devices

In the first versions of ASP.NET, the development of web applications for mobile devices was only possible with an add-on called Mobile Internet Toolkit, which contained a set of special controls. Since version 1.1, these controls, now named Mobile Controls, are shipped with the framework.

Again, in version 2.0 there are some changes. The old controls are still included, but only for compatibility reasons. They aren't recommended for use.

The new magic phrase is "adaptive rendering." In other words, no special controls are needed for mobile devices anymore! Regular web controls will change their presentation depending on the target device. A set of adapter classes can be assigned to each control. A number of these adapters are included for common browsers and mobile devices, but you can define your own, too. These classes will do the alternative rendering. The advantage is that updates or enhancements for existing or new controls can be integrated at a later date—for example, when a new type of mobile device comes to market.

Irrespective of this new generic concept, a set of new controls still target mobile devices (see Figure 1-10). For example, a troika of controls, MultiView, View, and Pager, will help you to implement the presentation of content like the cards in Wireless Markup Language (WML).

Figure 1-10: Use common controls to create mobile web apps. (Image courtesy Openwave Systems Inc.)

Site Counters

This is a nice feature for counting not only page requests but also clicks of controls like AdRotator, Button, LinkButton, or even HyperLink. The ASP.NET Framework will provide you with an extensive API to analyze, visualize, and process the data.


In former versions of ASP.NET, the configuration of both desktop and web applications was hardly perfect. Granted, XML configuration files had a big advantage over the IIS Metabase (a registry-like configuration store used mainly in "classic" ASP). But the increasingly large amount of information placed inside these web configuration files made them very quickly become complex to administer. Until now, changes were possible only by modifying the file manually or by editing the XML data individually, for example, by using use a third-party tool. Not to mention that every change in the web.config file required a complete restart of the application.

Now with ASP.NET version 2.0, a voluminous API to read and write configuration files like web.config in a type-safe manner is delivered with the new .NET Framework. In typical OOP manner, you get one corresponding object per configuration segment and a whole collection where necessary. You can edit these objects and finally save them back to the file. From now on, you can control every setting of your web application within the application, at your local system and remotely.

Two examples for the use of the API are already shipped with the framework. You've seen a new tool called Web Site Administration in the earlier description of the user management system (refer back to Figures 1-5 and 1-6). This extensive back end is automatically available for administrators of a web site. Users and roles, for example, can be managed with this tool. Starting with the Beta version, a number of additional functions such as features for analyzing the site counters will be available.

Although the Web Site Administration tool, as the name implies, addresses the administration of web applications by web masters and editors, a second tool, known as the Configuration Settings Editor, is optimized for the needs of the server administrator. Naturally, server administrators are recognized as having better knowledge of the details, and therefore will get much more out of the Configuration Settings Editor to fine-tune the application. Basically, this feature is an extension of the IIS MMC Snap-In, which enables you to edit virtually every setting in the web.config file and more. Several parts can be locked down, so an ISP or hosting company can restrict the configuration possibilities for specific web accounts. This is both an advantage in terms of security and in offering new, interesting business models, such as the activation and deactivation of features for a higher monthly fee. All functions of this tool are also available if you use remote access. Figure 1-11 shows the tool in action.

Click To expand
Figure 1-11: The Configuration Settings Editor allows editing of virtually any setting by enhancing the IIS MMC Snap-In.


Installation and distribution of applications is an important issue, but no convenient end-to-end solution existed in the previous versions of ASP.NET. The new version offers several new possibilities. First, you can now create or open projects by using either the file system, the local IIS, FrontPage Extensions, or even FTP. An assistant called Web Copy, which will be implemented in the upcoming Beta version, supports you by synchronizing your local development version with the live server.

Next, there is an interesting new functionality for compiling complete web applications. The primary results of this compilation are some dynamic link libraries (DLLs), which can easily be copied to the web server. These DLLs not only include the compiled source code, but also contain the content of the ASPX and ASCX files. This means that no design-time files will need to be placed on the server, and therefore the application itself can't be modified.


So what's up? A little bit curious? The new features promise a lot, don't you think? The enhanced features cover many scenarios that you've previously had to implement manually in the past. The ASP.NET team has come very close to the goal of reducing by 70% the source code you as the developer have to write.

Team LiB
Previous Section Next Section