Visual Studio 2005 and the new version of ASP.NET introduce a large number of control enhancements and a similar number of new controls. Wherever you turn in the product, there is something new, designed to make you more productive. We have already covered a few of these new items in this chapter. Our intent for the following sections is to call out some of the major enhancements as well as walk you through the new controls. ASP.NET Control EnhancementsMost control enhancements apply to the entire group of ASP.NET controls. This is due to the fact that they are all built on the same control framework. Control enhancements include
This list represents some of the big enhancements. However, each control has its own set of new features and enhancements. If you are familiar with prior versions of .NET, you should be sure to look for any feature you previously felt was missing. The New Controls Inside ASP.NETThe Visual Studio Toolbox continues to grow. In fact, there are whole new sets of controls. For example, we have already looked at the new Web Part family of controls. Another set of controls exist for managing user logins and security. In addition, Visual Studio now has controls that help you better define site navigation. There are also new data source controls and a new grid in which to display data. There is a new wizard control for defining multistep processes in the UI, a new control for uploading files, an image map control, and so on. The list of new (and improved) controls is a large one. The following sections examine a number of these new controls. Note If you still can't find the perfect control, Visual Studio provides you with the framework to create your own controls. You can take the simple approach and define a user control. This is a file that you can design like a page and then use across other pages. User controls are made up of one or more existing ASP.NET controls. They also have their own code-behind file for processing their own events. In this latest version of Visual Studio, user controls are also shown inside the designer (previously, they were just gray boxes). If a user control is still not right and you want to provide design-time support for the Toolbox, configuration, and the Properties window, then you can create a custom control. Custom controls follow the same framework as the existing ASP.NET controls. You can even subclass and extend an existing control and turn it into your own custom version. Login ControlsASP.NET has a built-in set of login controls. These controls are meant to provide a complete low-code (sometimes no-code) solution for managing and authenticating users inside web applications. By default, the login controls use what is called ASP.NET Membership. This feature allows these controls to work with an authentication database and related features without your writing code. Membership allows for the creation of users and groups and the management of user data (including passwords). The membership services inside ASP.NET can work with a SQL Express database or Active Directory. You can also write your own custom provider that can be plugged into the model. We will look at configuring membership in a moment. First, let's examine the many login controls. Figure 13.41 shows a list of all these controls in the Toolbox. Each control has a purpose and is aptly named. Table 13.5 provides a brief overview of these many controls. Figure 13.41. The login controls for ASP.NET.
Configuring User AuthenticationYou can create a login page (or control) by dropping the Login control directly on a form. After you place it, you can begin to set the properties that define your application's security. Figure 13.42 shows an example. Notice that the login control provides access to the Administer Website link. This link takes you to the Web Site Administration Tool (WSAT) for your site where you can begin to define your authentication. Figure 13.42. The Login control.Note By default, user data is sent to the server from the client as plain text. Therefore, you should enable SSL and HTTPS for securing your site. The WSAT is a web-based tool that allows you to configure your site, including security. Figure 13.43 shows the home page of the tool. From here, you can access the Security tab, define application configuration (turn on tracing, for example), and select an administration provider. The default administration provider is configured for SQL Server or SQL Express. This is the place where the configuration data (such as users) for your site is stored. Figure 13.43. The ASP.NET Web Site Administration Tool (WSAT).You can use the WSAT to change from Windows security to Internet security. The former is best when working on a LAN environment. The latter is required for most public-facing, secure sites. After you configure this model, ASP switches you over to using membership. As a result, you get a membership database. You can use the Security tab, shown in Figure 13.44, inside WSAT to configure the users, roles, and access for this database. Notice the three groups at the bottom of the screen: Users, Roles, and Access Rules. These groups provide links for managing the accounts in your system. Your login control will automatically respect the information configured here. Figure 13.44. Managing users and roles for your site.Site Navigation ControlsIt can be easy to become lost on a lot of websites out there. If you don't provide good user navigation, then chances are users will complain (or stop visiting). ASP provides a few controls to help deal with defining and controlling navigation. The controls include the following:
Using the SiteMapPath ControlRecall that the SiteMapPath control is used to orient users in your site. You control this orientation definition through the use of a .sitemap file. You add this file to your site through the Add New Item dialog box. Inside it, you define the logical hierarchy of your site by nesting pages inside siteMapNode elements. For example, if users start at a home page, this would be your outer node. As they navigate into your site, you create nested nodes. Listing 13.4 shows a simple example that includes a three-tier definition: Home, Find Customer, Edit Customer. This makes a logical progression through the sample site. Listing 13.4. A .sitemap File
Figure 13.45 shows the results users see in their browser. In this case, the SiteMapPath control was added to the master page so that it appears throughout the site. Figure 13.45. The SiteMapPath control in action.Data ControlsASP.NET has a full set of controls that you can use for working with, displaying, and binding to data. These controls are meant to work with little to no additional code. Instead of writing code, you should be able to configure the controls to behave as you want. Figure 13.46 shows a list of all the data controls in the Toolbox. Table 13.6 provides a brief overview of each of these controls. Figure 13.46. The data controls in ASP.NET.
Note We will cover ways to work with data and databases in Chapter 15, "Working with Databases." |