</asp:Menu>
</div>
<!-- Content -->
<div class="Content">
<asp:ContentPlaceHolder id="ContentPlaceHolder1"
runat="server" />
</div>
</form>
</body>
The code is pretty simple: basically, it defines the layout of all the Dorknozzle
pages. Each of the three sections defined here starts with a comment that identifies
the section as being the header, the menu on the left, or the content area. These
elements are positioned on the page using the CSS styles you added earlier to
the Dorknozzle.css file, so you may want to have another look at that file to
refresh your memory.
We saw in Chapter 4 that the TreeView and Menu controls know how to read
data from a SiteMapDataSource class, which reads the Web.sitemap file located
in the root of your project (unless you specify otherwise). To build the menu on
the left-hand side of the page, we create a Web.sitemap file, then add a
SiteMapDataSource control to our web form or master page:
File: Dorknozzle.master (excerpt)
<asp:SiteMapDataSource id="dorknozzleSiteMap" runat="server"
ShowStartingNode="false" />
You might recall that the Web.sitemap file forces us to add a root siteMapNode
element, but we can suppress this root element using the SiteMapDataSource—we
set its ShowStartingNode property to False.
To have the Menu control simply display the list of nodes, it’s sufficient to set its
DataSourceID to the ID of the SiteMapDataSource. However, the Menu control
also gives us the potential to customize the look of each menu item through
templates. Here, we used the StaticItemTemplate to add a little book image
to the left of each menu item:
File: Dorknozzle.master (excerpt)
<asp:Menu id="dorknozzleMenu" runat="server"
DataSourceID="dorknozzleSiteMap">
<StaticItemTemplate>
<img src="Images/book_closed.gif" alt="+"
width="16" height="16" style="border-width: 0;" />
<%# Eval("Text") %>
197
Building the Master Page