Microsoft Virtual Labs ®
ASP.NET 2.0 User Interface Enhancements: Master Pages, Themes, and Controls
ASP.NET 2.0 User Interface Enhancements: Master Pages, Themes, and Controls
Table of Contents ASP.NET 2.0 User Interface Enhancements: Master Pages, Themes, and Controls ............. 1 Exercise 1 Create a Master Page ...................................................................................................................................2 Exercise 2 Theme the Web Site’s Pages........................................................................................................................5 Exercise 3 Add Multiple Views.....................................................................................................................................7
ASP.NET 2.0 User Interface Enhancements: Master Pages, Themes, and Controls
ASP.NET 2.0 User Interface Enhancements: Master Pages, Themes, and Controls Objectives
Scenario
After completing this lab, you will be better able to: Build a master page Convert existing pages into content pages Apply themes to a site Use MultiView controls to implement multiple views Interactively switch between views in MultiView controls Use custom HTTP handlers to render images retrieved from a database ASP.NET 2.0 provides a wide range of new features to simplify the development of user interfaces, from master pages, themes, and skins to more than 50 new controls designed to make short work of implementing common user interface elements. In this lab, you’ll get first-hand experience using these new features by giving the MyComics application you started in Lab 2 a face-lift. First, you’ll add a master page to the site. Next, you’ll theme the site using a custom theme. Finally, you’ll use a MultiView control to offers users a choice of ways to view comic book data, and you’ll combine DataList controls and custom HTTP handlers to implement a new view of the comic database
Estimated Time to Complete This Lab
60 Minutes
Page 1 of 10
ASP.NET 2.0 User Interface Enhancements: Master Pages, Themes, and Controls
Exercise 1 Create a Master Page Scenario In this exercise, you’ll create a master page to serve Default.aspx, Details.aspx, Admin.aspx, and other pages that will be added later. Then you’ll modify the existing pages by turning them into content pages. Tasks
Detailed Steps
1. Enable database
a. Click Start | All Programs | Microsoft Visual Studio 2005 | Visual Studio Tools | Visual Studio 2005 Command Prompt. b. Navigate to the C:\MSLabs\ASP.NET\LabFiles\Database directory. c. Type CacheSetup. d. Close the Visual Studio 2005 Command Prompt.
caching.
2. Open the Web site.
a. Click Start | All Programs | Microsoft Visual Studio 2005 | Microsoft Visual Studio 2005. b. Click File | Open Web Site and navigate to C:\MSLabs\ASP.NET\Starter\
\Lab3 and click Open. Note: This lab supports either C# or VB languages. c. In the Solution Explorer right-click C:\..\Lab3, select New Folder and name it Images. d. Right-click the Images folder and select Add Existing Item. e. Navigate to C:\MSLabs\ASP.NET\LabFiles\Images select MyComics.gif and click Add.
3. Add a master page to
a. In the Solution Explorer right-click C:\..\Lab3 and select Add New Item.
the site.
4. Define the layout of
the master page.
b. In the Add New Item dialog select Master Page as the template type and name the master page Site.master. c. Ensure that C# or Visual Basic is selected in the Language box and that Place code in separate file is checked and click Add. d. In the Target Schema for Validation drop-down list on the toolbar select Internet Explorer 6.0. e. Click the Design button to switch to Design view. a. Click Layout | Insert Table. b. In the Insert Table dialog click the Template button, select Header, footer, and side from the drop-down list and click OK. c. Drag the ContentPlaceHolder control to the right-hand cell of the table’s second row. d. Place the cursor in that cell (not in the ContentPlaceHolder) and in the Properties window set the VAlign property to top. The ContentPlaceHolder control should snap to the top of the cell e. Right-click the top row of the table and select Insert | Row Below from the context menu. f. Select the new row and in the Properties window set the Height property to 1 and the BgColor property to Gray. g. Right-click the bottom row of the table and select Insert | Row Above from the Page 2 of 10
ASP.NET 2.0 User Interface Enhancements: Master Pages, Themes, and Controls Tasks
Detailed Steps h. i. j. k. l. m. n.
context menu. Select the new row and in the Properties window set the Height property to 1 and the BgColor property to Gray. Right-click the cell to the left of the one that contains the ContentPlaceHolder control and select Insert | Column to the Right. Select the new cell and in the Properties window set the Width property to 1 and the BgColor property to Gray. Select the top row of the table and in the Properties window set the BgColor property to #105070. Put the cursor in the leftmost cell in the table’s middle row and in the Properties window set the BgColor property to #ececec. Select the bottom row of the table and in the Properties window set the BgColor property to #ececec. Click the Source button and manually modify the tag to look like this:
o. Click the Design button to view the master page in Design view. 5. Add content to the
master page.
6. Convert existing
pages into content pages.
a. From the Toolbox, under Standard, drag a HyperLink control and drop it into the top row of the table. b. In the Properties window set the ImageUrl property to ~/Images/MyComics.gif and the NavigateUrl property to ~/Default.aspx. c. Select the top row of the table and in the Properties window set the Height property to 1 so the height will adjust to fit the image. d. Put the cursor in the leftmost cell in the middle row of the table and in the Properties window set the Width property to 128. e. Select the bottom row of the table and in the Properties window set the Height property to 16. f. Click the cursor in the bottom row, select 8pt from the Font Size drop-down and Verdana from the Font Name drop-down. g. Type If this page works, I built it. If it doesn’t work, I don’t know who built it. a. In Solution Explorer double-click Default.aspx and click the Source button. b. In the Source view add a MasterPageFile=”~/Site.master” attribute to the @ Page directive at the top of the page. c. Remove the , , , ,