I got a little stumped this week and turned to the fountain of software knowledge, also known as Stack Overflow, with a question about Missing popout class in ASP.NET menu for nodes without a URL. The problem is simply this; let’s take the following Web.sitemap file:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<siteMapNode url="" title="" description="">
<siteMapNode title="Top 1" url="~/Top1.aspx">
<siteMapNode title="Sub 1" url="~/Sub1.aspx" />
</siteMapNode>
<siteMapNode title="Top 2">
<siteMapNode title="Sub 2" url="~/Sub2.aspx" />
</siteMapNode>
</siteMapNode>
</siteMap>
Now for an absolute bare bones implementation of a sitemap data source and menu control:
<asp:Menu runat="server" DataSourceID="menuDs" Orientation="Horizontal" />
<asp:SiteMapDataSource ID="menuDs" runat="server" ShowStartingNode="false" />
So here’s the question: will the sitemap node titled “Top 2” display a pop out icon to indicate there’s content beneath it or not? Note that it doesn’t have a URL defined.
The answer depends on the version of .NET the code runs against or more specifically, what version the control rendering runs against. Here’s how it looks when running against .NET3.5 or against .NET4 with the controlRenderingCompatibilityVersion attribute set to 3.5: