RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


What's New in ASP.NET 3.5? : Page 3

For those of you who have been sitting on the sideline waiting for "Orcas" to ship before you take a look at the new features in ASP.NET 3.5, it's time for you to get in the game.

ASP.NET 3.5-Related Visual Studio 2008 Enhancements
The Visual Studio 2008 IDE has been enhanced to improve your productivity when developing Web applications.

Nested Master Pages Support
Figure 9. Nested Master Page Template: The Nested Master Page template has been added to the Add New Item dialog box.
I have personally been waiting for this one for a while now. While the concept of nested master pages isn't new to ASP.NET 3.5, as you are probably aware, Visual Studio 2005 didn't really support nested master pages. The problem was that pages based on master pages could not be edited within the Visual Studio 2005 designer. Microsoft has corrected this behavior with Visual Studio 2008.

The process for creating a nested master page is slightly different depending on which project model you are using: Web Site or Web Application Project. I'll use a project based on the Web Application Project model for this example. I'll add a new item to a project and select the Nested Master Page template and enter a name for the nested master. I selected Training.master (see Figure 9). Next, need to select the master page I want to base my nested master page on. I selected a master page named TakeNote.master (see Figure 10). The TakeNote.master page contains a graphic, menu structure, a single content place holder, and page footer (see Figure 11).

Figure 10. Select Master: Select the master template you wish to base your nested master page on.
Figure 11. Basic Master Page: This master page contains a header, menu, and footer.

A common scenario for nested master pages is creating a master page for each department within an organization. Using the TakeNote.master as a base master page I could create nested master pages for departments such as training or consulting and customize them with text and graphics specific to that department. New pages for each department would use the department-specific nested master page. With this scenario mind I have added a heading and ContentPlaceHolder control in the Training.master as shown below:

   <%@ Master Language="VB" MasterPageFile="~/TakeNote.Master" 
     AutoEventWireup="false" CodeBehind="Training.master.vb" 
     Inherits="TakeNote.Training1" %>
     <asp:Content ID="Content1"
       <asp:ContentPlaceHolder ID="ContentPlaceHolder1" 
         runat="server" />
The process for creating a new page from a nested master page is the same as it was in ASP.NET 2.0. The good news is that now you can work with the new nested master page based in the WYSIWYG Designer in Visual Studio 2008.

Multi-Framework Targeting
I never gave it much thought at the time but previous versions of Visual Studio were tied to a specific version of the .NET Framework. For example, when Visual Studio 2005 was released you created applications based on .NET 2.0. That started to change a bit when Microsoft released .NET 3.0, because you could extend Visual Studio 2005 to create .NET 2.0 and .NET 3.0 applications.

Figure 12. Target Framework Version: You can target a specific framework version when creating a new Web site.
With the release of Visual Studio 2008 Microsoft has taken that idea to the next logical step. When you open an existing project, or create a new one, you are given the option to select which framework version you want to target (see Figure 12). The Visual Studio 2008 IDE will adjust itself to your framework selection and only offer features, options, controls, templates, and assemblies, among other things, based on the targeted framework. This includes automatically updating the assemblies referenced in your project and sections in the Web.config file.

One of the benefits of the multi-framework targeting support is that all the new features added to Visual Studio 2008, such as nested master page support, enhanced JavaScript support, and the HTML editor enhancements, are available to you as you continue to work on and support your ASP.NET 2.0-based Web sites. Yes, you read that right. You can use Visual Studio 2008 to open your ASP.NET 2.0 projects without upgrading them to the .NET 3.5 framework while taking advantage of all the new Visual Studio enhancements.

The process of specifying which version of the .NET Framework to target for an existing project depends on which project model you are using and unfortunately, which language you are using. If you are using the Web Site project model, regardless of the language selected, select the Build option on the project Property Pages and select the framework you want to target from the dropdown (see Figure 13). If you are using the Web Application project model, here is where things get interesting. For projects written in C#, things are simple. Open the project properties and select the framework you wish to target on the Application tab (see Figure 14). For Visual Basic projects created with the Web Application Projects model, open the project properties, select the Compile tab, and click the Advanced Compile Options button. Select the framework from the Target framework dropdown (see Figure 15).

Figure 13. Target Framework from Project Properties: For existing Web site projects you can specify the target framework from the project properties.
Figure 14. Targeting Framework in C#: For C# Web application projects you can specify the target framework from the Application tab on the Property Pages.
Figure 15. Targeting Framework in VB: For Visual Basic Web application projects you can specify the target framework on the Advanced Compiler Settings dialog box.

Note that Visual Studio 2008 only supports targeting your application to version 2.0 and higher, so you won't see versions 1.0 and 1.1 of the .NET Framework as options.

I encourage you to experiment with changing the target framework on a sample project and take a look at the changes Visual Studio 2008 implements automatically.

Enhanced Web Designer
Figure 16. Split Pane: The Split pane enables you to see the HTML source and Design surface at the same time.
Visual Studio 2008 and Expression Web now share the same visual Web designer. This is a welcome change, because the first time you jump from the Design pane to the Source pane and back again, you will find that performance has improved and additional functionality has been added.

The Split View feature displays the Design View and the HTML source in two different panes at the same time (see Figure 16). While in Split View, changes you make in the Design pane automatically updates the source in the HTML pane. You would expect that changes you make in the HTML source pane would automatically be reflected in the Design pane, right? Wrong. You need to either save the page or click the button displayed at the top of the Design pane to synchronize the two panes.

By default, the two panes are split horizontally with the HTML pane on top and the Design pane on the bottom. To display the two panes side-by-side, from the Tools menu select Options, make sure "Show All Settings" is checked, drill into the HTML Designer option, select General, and check the Split views vertically option (see Figure 17).

Figure 17. Split Pane View Options: You can specify a vertical or horizontal display for the Split pane.
Figure 18. HTML/CSS Error Options: Select the option for HTML and CSS warnings to stop getting them listed as errors.

While you view the Options dialog box, let me point out a nice addition made to Visual Studio 2008. Select the Text Editor option, drill into the HTML option and select the Validation option. Right out of the box, Visual Studio 2008 is configured to display those pesky HTML, CSS, and JavaScript errors as warnings instead of errors (see Figure 18).

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date