The SiteMapDataSource control enables you to view navigation information in your web application. You can use the C1WebTreeView and C1WebMenu control with the SiteMapDataSource.
1. Start a new Web Site project
2. Right-click on the project in the Solution Explorer and select Add New Item. The Add New Item dialog box appears. Select Site Map from the list of templates, and then click Add to add the new Web.sitemap item to the project.
3. Switch to the sitemap view and add the following data to the Web.sitemap file:
<siteMap>
<siteMapNode title="Home" description="Home" url="~/default.aspx">
<siteMapNode title="Products" description="Our products"
url="~/Products.aspx">
<siteMapNode title="Hardware" description="Hardware choices"
url="~/Hardware.aspx" />
<siteMapNode title="Software" description="Software choices"
url="~/Software.aspx" />
</siteMapNode>
<siteMapNode title="Services" description="Services we offer"
url="~/Services.aspx">
<siteMapNode title="Training" description="Training classes"
url="~/Training.aspx" />
<siteMapNode title="Consulting" description="Consulting services"
url="~/Consulting.aspx" />
<siteMapNode title="Support" description="Supports plans"
url="~/Support.aspx" />
</siteMapNode>
</siteMapNode>
</siteMap>
4. Select the Data tab in the Visual Studio Toolbox and add the SiteMapDataSource component to the web page using a drag-and-drop operation.
5. Add a C1WebTreeView control to the web form.
6. Right-click the control and select Show Smart Tag.
7. On the C1WebTreeView Task menu, select the SiteMapDataSource1 value from the Choose Data Source dropdown box. Note that you may also set the DataSourceID property from the Properties window.
8. Run the project and observe the following:
· The items’ Text correspond to the sitemapnode title attributes.
· The items’ Tooltips correspond to the sitemapnode description attributes.
· The items’ NavigateUrls correspond to the sitemapnode url attributes.
· If you don’t want to show root node, set SiteMapDataSource.ShowStartingNode = False.
You can follow the preceding steps to bind an XML data source to a C1WebMenu. Instead of adding a C1WebTreeView control add a C1WebMenu control to your Web site page. The same sitemap appears like the following image for a C1WebMenu control:
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |