Missing popout class in ASP.NET menu for nodes without URL

I have a little problem with a dropdown icon in an ASP control that doesn't appear when the site map node does not have a url. Take the following site map 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 element - Top 1 - gets a CSS pop-up class written for the tag that spans the label. However, the second top-level element - Top 2 - does not receive the class. Given that this class is usually used to hold an arrow indicating that there is more content below the element, here is a bit of usability problem.

Does anyone have a workaround? Or, alternatively, is this a node sitemap without a URL attribute that somehow violates the intended use of the control?

Edit: this problem was fixed in .NET 4.5: https://connect.microsoft.com/VisualStudio/feedback/details/600069/sitemap-menu-nodes-without-a-url-dont-display-a-popout -image-when-child-nodes-exist

+3
source share
3 answers

So it looks like this behavior only happens in ASP.NET4, and everything was fine in previous versions. I call this an error in the new control rendering mode. More details here: http://www.troyhunt.com/2010/09/net4-web-apps-and-mysteriously-absent.html

+1
source

, , jquery. ! jquery . ( , ) , . , !

<script language="javascript" type="text/javascript">
    //the following script adds the triangles back into the menu for items that don't directly link to anything.
    $(document).ready(function () {
        $("li > a.static").each(function () {
            if ($(this).parent().children().length > 1) {
                $(this).addClass("popout");
            }
        });          
    });
</script>
+1

Try setting the url property to #:

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

The likely cause of the error is that, without the url field, the node is not a link, and CSS is set for link references.

0
source

Source: https://habr.com/ru/post/1764427/


All Articles