Thursday, March 22, 2012

web.sitemap question

I want to create a web.sitemap file that represents a menu, but I just
can't figure this out! I need multiple "top level" menu items. Like
"Home", "Support", "Contact Us", etc. Under some of these top level
items, would be sub items. So in a dynamic menu, the sub item would
drop down when moused over.
The problem is that .net 2.0 gives an error if I have more than one
SiteMapNode directly under the SiteMap tag. For example, I can't do
this: (for simplicity, i didn't include code for the sub-items)
<siteMap>
<siteMapNode title="Home" />
<siteMapNode title="Support" />
<siteMapNode title="Contact Us" />
</siteMap>
So how can I have multiple Top Level menu items using web.sitemap?
Thanks!
JohnJust figured it out. Here's the solution:
<siteMap>
<siteMapNode>
<siteMapNode title="Home" />
<siteMapNode title="Support" />
<siteMapNode title="Contact Us" />
</siteMapNode>
</siteMap>
The "top level" items are actually sub items. By default doing this
doesn't work because the root siteMapNode doesn't have any value.
I had to add ShowStartingNode="False" here:
<asp:SiteMapDataSource ID="SiteMapDataSource1"
ShowStartingNode="False" runat="server" />
That fixed the problem. :)
John

0 comments:

Post a Comment