3. TreeView
• The TreeView server control is a rich server control for
rendering a hierarchy of data, so it is quite ideal for displaying
what is contained in your .sitemap file.
• <p>
• <asp:TreeView ID="TreeView1" runat="server"
DataSourceID="SiteMapDataSource1">
• </asp:TreeView>
• <asp:SiteMapDataSource ID="SiteMapDataSource1"
runat="server" /></p>
• This TreeView control is very basic. The great thing about this
control is that it allows for a high degree of customization and
even gives you the capability to use some predefined styles
that come prepackaged with ASP.NET 4.
4. Menu Server Control
• One of the cooler navigation controls found in ASP.NET 4 is
the Menu server control. This control is ideal for allowing the
end user to navigate a larger hierarchy of options while
utilizing very little browser real estate in the process.
• From here, you can see that the first Menu control displayed
simply shows the Home link with a small arrow to the right of
the display. The arrow means that more options are available
that relate to this upmost link in the hierarchy. The second
Menu control displayed shows what the default control looks
like when the end user works down one of the branches
provided by the sitemap.
• The Menu control is an ideal control to use when you have lots
of options—whether these options are selections the end user
can make or navigation points provided by the application in
which they are working. The Menu control can provide a
multitude of options and consumes little space in the process.
5. • Using the Menu control in your ASP.NET applications is
rather simple. The Menu control works with a
SiteMapDataSource control. You can drag and drop the
SiteMapDataSource control and the Menu control onto the
Visual Studio 2010 design surface and connect the two by
using the Menu control’s DataSourceId property.
Alternatively, you can create and connect them directly in
code.
<form id="form1" runat="server">
<div>
<asp:SiteMapDataSource ID="aa" runat="server" />
<asp:Menu ID="Menu1" runat="server"
DataSourceID="aa">
</asp:Menu></div>
</form>