菜单视图中只有子菜单可以重定向 [英] Only sub menus in Menu View can redirect

查看:61
本文介绍了菜单视图中只有子菜单可以重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨.

原谅我我不会写好英语.


以下菜单项不希望任何人拥有该页面的链接.
但是那些拥有子菜单的人没有任何点击.
在下面可以看到我的代码
请帮助我进行更改.


Menu.aspx.cs

Hi.

Forgive me I can not write good English.


The following menu items that do not want just anyone have a link to the page.
But those who have sub-menu click on them nothing happens.
Below you can see my code
Please help me with changing it.


Menu.aspx.cs

DataSet ds = new DataSet();
string connStr = @"Data Source=.;Initial Catalog=Azad;Integrated Security=True";
using (SqlConnection conn = new SqlConnection(connStr))
{
    string sql = "Select MenuID, Text, Description, ParentID from Menu";
    SqlDataAdapter da = new SqlDataAdapter(sql, conn);
    da.Fill(ds);
    da.Dispose();
}
ds.DataSetName = "Menus";
ds.Tables[0].TableName = "Menu";
DataRelation relation = new DataRelation("ParentChild",
        ds.Tables["Menu"].Columns["MenuID"],
        ds.Tables["Menu"].Columns["ParentID"],
        true);

relation.Nested = true;
ds.Relations.Add(relation);



Menu.aspx



Menu.aspx

<form id="form1"  runat="server">
    <div>
       <asp:Menu ID="Menu1" DataSourceID="xmlDataSource" runat="server" 

          BackColor="#FFFBD6" DynamicHorizontalOffset="2" Font-Names="Verdana" 

          ForeColor="#990000" StaticSubMenuIndent="10px" StaticDisplayLevels="1" Orientation="Horizontal">
          <DataBindings>
            <asp:MenuItemBinding DataMember="MenuItem" 

             NavigateUrlField="NavigateUrl" TextField="Title" />
          </DataBindings>
          <StaticSelectedStyle BackColor="#FFCC66" />
          <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
          <DynamicMenuStyle BackColor="#FFFBD6" />
          <DynamicSelectedStyle BackColor="#FFCC66" />
          <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
          <DynamicHoverStyle BackColor="#990000" Font-Bold="False" ForeColor="White"/>
          <StaticHoverStyle BackColor="#990000" Font-Bold="False" ForeColor="White" />
       </asp:Menu>
       <asp:XmlDataSource ID="xmlDataSource" TransformFile="~/TransformXSLT.xsl"  

          XPath="MenuItems/MenuItem" runat="server" EnableCaching="False" 

            EnableViewState="False"/> 
    </div>
    </form>



TransformXSLT.xsl



TransformXSLT.xsl

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" encoding="utf-8"/>
  <!-- Find the root node called Menus 
       and call MenuListing for its children -->
  <xsl:template match="/Menus">
    <MenuItems>
      <xsl:call-template name="MenuListing" />
    </MenuItems>
  </xsl:template>
  
  <!-- Allow for recusive child node processing -->
  <xsl:template name="MenuListing">
    <xsl:apply-templates select="Menu" />
  </xsl:template>
  
  <xsl:template match="Menu">
    <MenuItem>
      <!-- Convert Menu child elements to MenuItem attributes -->
      <xsl:attribute name="Title">
        <xsl:value-of select="Title"/>
      </xsl:attribute>
		
      <!--<xsl:attribute name="ToolTip">
        <xsl:value-of select="Description"/>
      </xsl:attribute>-->
		
      <xsl:attribute name="NavigateUrl">
        <xsl:text>?Sel=</xsl:text>
        <xsl:value-of select="ID"/>
      </xsl:attribute>
      
      <!-- Call MenuListing if there are child Menu nodes -->
      <xsl:if test="count(Menu) > 0">
		  <xsl:call-template name="MenuListing" />
      </xsl:if>
    </MenuItem>
  </xsl:template>
</xsl:stylesheet>

推荐答案

我认为您想显示这些选项,但不适用于某些用户.我不确定XSLT是否可以执行此操作,除非您插入XSLT可以查找的属性.另一种方法是从传递给XSLT的XML中剥离您不想使用的页面的URL.
I THINK you want to show the options but not have them work for some users. I am not sure an XSLT can do this, unless you insert attributes the XSLT can look for. The alternative is to just strip the URLs for the pages you don''t want to work, from the XML you pass in to the XSLT.


这篇关于菜单视图中只有子菜单可以重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆