views:

61

answers:

2

I’m having a little problem with the popout icon in the ASP menu control not appearing when the sitemap node doesn’t have a URL. Take the following sitemap nodes as an example:

<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>

The first top level item – Top 1 – gets a popout CSS class written to the tag that spans the label. However the second top level item – Top 2 – does not get the class. Given this class is generally used to hold the arrow indicating there’s more content beneath the item there’s a bit of a usability problem here.

Does anyone have a workaround for this? Or alternatively, is a sitemap node without a URL attribute somehow breaking the intended usage of the control?

A: 

Try setting the url property to #:

<siteMapNode title="Top 2" url="#">

Probable cause of error is that without url field, the node is not link, and CSS is set to apply on links.

Ivan Ferić
Except of course the hash symbol means it WILL link - to the current page. I don't want it to link anywhere, it's just a container for the child items.
Troy Hunt
Although this is link, it doesn't refresh the page - it just tells the browser to set the focus to the anchor with name "". Since there is no anchor with that name, the only effect that you get by clicking on this link is that it will scroll the page to the top - without refreshing.
Ivan Ferić
But it's also semantically wrong; as I've said in the blog post referenced in my answer, much of the objective for changing the HTML rendering in the ASP.NET4 controls was to get greater alignment with natural HTML intent and be more accessible. Having an href attribute on the tag is just not right as the text is not actually intended to link anywhere!
Troy Hunt
Well, you asked me for a workaround. Whether it's semantically wrong or not is open for discussion. But this IS a workaround and it works in all major browsers.
Ivan Ferić
You're right about that Ivan, thanks very much for the suggestion. Hopefully this is something MS can pick up and resolve in the future.
Troy Hunt
A: 

So it appears this behaviour is only occurring in ASP.NET4 and was all good in previous versions. I'm calling this one as a bug in the newer control rendering mode. More info here: http://www.troyhunt.com/2010/09/net4-web-apps-and-mysteriously-absent.html

Troy Hunt