ASP.NET 菜单中缺少没有 URL 的节点的弹出类

发布于 2024-09-18 10:49:48 字数 862 浏览 7 评论 0原文

我遇到了一个小问题,当站点地图节点没有 URL 时,ASP 菜单控件中的弹出图标不会出现。以以下站点地图节点为例:

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

第一个顶级项目 – Top 1 – 将弹出 CSS 类写入跨越标签的标签。然而,第二个顶级项目——Top 2——没有获得该类别。鉴于此类通常用于容纳箭头,指示该项目下方有更多内容,因此这里存在一些可用性问题。

有人有解决方法吗?或者,没有 URL 属性的站点地图节点是否会以某种方式破坏控件的预期用途?

编辑:此问题已在 .NET 4.5 中修复: https://connect.microsoft.com/VisualStudio/feedback/details/600069/sitemap-menu-nodes-without-a- url-不显示-popout-image-when-child-nodes-exist

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?

Edit: This issue has been 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

懒猫 2024-09-25 10:49:48

因此,这种行为似乎只发生在 ASP.NET4 中,并且在以前的版本中一切正常。我将此称为较新的控件渲染模式中的错误。更多信息请参见:http://www. troyhunt.com/2010/09/net4-web-apps-and-mysteriously-absent.html

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

街角迷惘 2024-09-25 10:49:48

因此,在寻找此问题的解决方案很长时间后,我偶然发现了使用 jquery 的建议。效果很好!只需导入 jquery 并将以下内容放入 head 标签中即可。它将把这些三角形(或您正在使用的任何东西)添加回其下有链接的节点。希望有帮助!

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

So, after looking for the fix to this for a long time I stumbled across a suggestion to use jquery. It works great! Just import jquery and put the following in your head tag. It will add those triangles (or whatever you are using) back to the nodes that have links under them. Hope it helps!

<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>
画骨成沙 2024-09-25 10:49:48

尝试将 url 属性设置为#:

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

错误的可能原因是没有 url 字段,该节点不是链接,并且 CSS 设置为应用于链接。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文