- •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
Chapter 2
Figure 2-16
Lost Windows
You may not be able to find some familiar windows in the Visual Studio 2005 release. For instance, when you open one of your ASP.NET applications in Visual Studio 2005, you do not see the Class View and Dynamic Help windows. Although not apparent in the default view when the IDE first opens, these windows are still available for use with your applications.
You can find the Class View by choosing View Other Windows Class View from the Visual Studio menu. The Class View window opens directly next to the Server Explorer. You can move the window wherever you want within the IDE.
You can find the Dynamic Help window by choosing Help Dynamic Help. Selecting this option opens the Dynamic Help window next to the Properties Window.
Other Common Visual Studio Activities
Visual Studio 2005 is so packed with functionality that it deserves a book of its own. This IDE is mammoth and enables you to do almost anything in the construction and management of your ASP.NET applications. This section takes a look at some of the common tasks that are done somewhat differently or in an altogether new manner in this latest release of Visual Studio.
34
Visual Studio 2005
Creating new projects
The process of creating new files and projects within Visual Studio 2005 is different than it was in Visual Studio 2002 or 2003. In this latest release of Visual Studio, the focus on project-based applications is gone. Now projects are created in a page-based manner. This means that when you create an ASP.NET application in Visual Studio, you don’t find solution or project files. In fact, when you first create the application, the only items created for you by the IDE include the project folder and a single .aspx file. If you are creating an ASP.NET page using the code-behind model, you also have an .aspx.vb or
.aspx.cs file.
One of the big changes you notice when opening the IDE is that no Start Page appears. You are presented with a blank IDE. You can create either a new single .aspx page or a Web site. To create a single page, simply go to the menu and choose File New File. To work on a previous file, choose File Open File. To create a new ASP.NET application, choose File New Web Site. You can see the dialog of options in Figure 2-17.
Figure 2-17
In most cases, you select the first option — ASP.NET Web Site. This creates a single folder for your application and a default .aspx page.
Making references to other objects
When you look at the Solution Explorer of your ASP.NET application, notice that the References and Web References folders are not present. How do you add these references to your file-based applications?
You can add them in a couple of ways, and both ways bring you to the same dialog within the IDE. The first way of adding references to your application is to highlight the solution in the Solution Explorer and then choose Web Site References from the Visual Studio menu. The second option is to right-click the solution in the Solution Explorer and select Property Pages from the list of options. Both methods bring up the Property Pages dialog shown in Figure 2-18.
35
Chapter 2
Figure 2-18
The Property Pages dialog allows you to make many modifications to your ASP.NET applications. For now, however, focus only on the first tab within the dialog — the References tab. When you have the References tab open, two enabled buttons appear at the bottom of the dialog — Add Reference and Add Web Reference.
The Add Reference button invokes the Add Reference dialog so that you can make a reference to a DLL to use in your project. Again in this version of Visual Studio, the objects are divided into categories such as .NET, COM, and others, as shown in Figure 2-19.
Figure 2-19
36
Visual Studio 2005
The Add Web References button invokes the Add Web Reference dialog (shown in Figure 2-20). Here you can make references to other Web services or .wsdl files found either in the same solution, on the same server, or on some remote server.
Figure 2-20
Be aware that these buttons have been added because no References or Web References folder appears in the Solution Explorer, which shows the referenced objects.
Using smart tags
The visual designer of Visual Studio now includes smart tags. Smart tags are a great enhancement to the development experience because they enable you to quickly program common tasks. Each smart tag is different and depends on the server control that it works with. For instance, the smart tag that appears for the GridView server control enables you to quickly apply paging and sorting of the data that the GridView displays. Other controls, however, may have different capabilities exposed through their respective smart tags.
Not every server control has a smart tag associated with it. If a server control does have this extra capability, you notice it after you drag and drop the control onto the design surface. After it is on the design surface, an arrow appears in the upper-right-hand corner of the control if a smart tag exists for that particular control. Clicking the arrow opens up the smart tag and all the options that the smart tag contains. This is illustrated in the GridView server control shown in Figure 2-21.
From the smart tag, you can select items either to add or alter by clicking one of the available links or by checking one of the available check boxes. When you have completed either of these actions, Visual Studio changes the code in the background — adding the capabilities that you want. You can also see the additions and modifications to the IDE if you change your view to the Code view of the page.
37
