Introduction to ASP.NET Web Forms 4

Version: 1.1.0


Through this hands-on lab you will understand some of the new features of WebForms 4 such as ClientID, Routing and granular control for ViewState.


ASP.NET 4 Web Forms provides enhancements in targeted areas and includes some new features. This Lab is also available online at and covers the following features:

  • New ASP.NET Project Templates: ASP.NET 4 Web Forms includes updated templates for creating new web applications and web sites. These templates include common functionality already implemented, which helps reducing the development time and provides guidance on best practices for building ASP.NET 4 Web applications.
  • Client IDs: Developers can now manage control IDs that affect rendered client IDs. The Control class now provides a new property called ClientIDMode that allows you to specify what behavior you want the runtime to take when determining whether or not to refactor the client ID upon rendering. This removes the previous bloat in the client ID.
  • URL Routing: ASP.NET 4 Web Forms introduces the new PageRouteHandler class that integrates URL Routing with Web Form Pages. URL routing in ASP.NET enables you to use URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs in a Web application that are descriptive of the user's action and are more easily understood by users and search engines. In URL routing, you define URL patterns that contain placeholders for values that are used when you handle URL requests. At run time, the pieces of the URL that follow the application name are parsed into discrete values, based on a URL pattern that you have defined.
  • View State: ASP.NET 4 Web Forms provides a more granular control over the View State. Developers can now disable the View State on a Page and enable it on specific server controls, and also disable it on a control an enable it on its childs.


In this Hands-On Lab, you will learn how to:

  • Take advantage of the new ASP.NET Project Templates
  • Control server control ClientIds
  • Enable bi-directional routing support
  • Control the View State at application and page level

System Requirements

You must have the following items to complete this lab:

  • Microsoft Visual Studio 2010
  • .NET Framework 4
  • Microsoft SQL Server 2008 (Express edition or above)
  • Adventure Works sample database

    the Dependency Checker will copy the Adventure Works sample database file on each exercise solution folder. If you wish you can copy it manually from the Assets folder.


All the requisites for this lab are verified using the Configuration Wizard. To make sure that everything is correctly configured, follow these steps:

To perform the setup steps you need to run the scripts in a command window with administrator privileges.

  1. Run the Configuration Wizard for the Training Kit if you have not done it previously. To do this, browse to Source\Setup folder of this lab, and double-click the Dependencies.dep file. Install any pre-requisites that are missing (rescanning if necessary) and complete the wizard.

    The Configuration Wizard is used for checking dependencies and setting up the environment. If the Configuration Wizard is not installed on your machine, you must install it running the DependencyChecker.msi file located on the %VS2010TKInstallationFolder%\Assets\DependencyChecker folder (e.g. by default the Training Kit is installed under C:\VS2010TrainingKit).

    For convenience, much of the code you will be managing along this lab is available as Visual Studio code snippets. The Dependencies.dep file launches the Visual Studio installer file that installs the code snippets.


This Hands-On Lab is comprised by the following exercises:

  1. Discovering the New ASP.NET Project Templates
  2. Controlling Server Control ClientIds
  3. Enabling Bi-Directional Routing Support
  4. Controlling the View State at Application and Page Levels

Estimated time to complete this lab: 90 minutes.

Each exercise is accompanied by an End folder containing the resulting solution you should obtain after completing the exercises. You can use this solution as a guide if you need additional help working through the exercises.

Each exercise contains a Visual Basic and a C# version; Inside the End/Begin solution folder you will find two folders: VB, containing the Visual Basic version of the exercise, and C#, containing the C# version of it.

Next Step

Exercise 1: New ASP.NET Project Templates