如果子菜单在菜单中有另一个子菜单时添加箭头符号,, 使用ASP,我想显示菜单,菜单包含4个项目,每个项目有子菜单,再次每个子菜单有另一个子菜单,在这个概念我想用箭头标记显示子菜单项,哪个子具有子菜单的菜单项表示它将显示该子菜单附近的箭头,我的vb编码喜欢
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim cmd As New SqlCommand
Dim data As New SqlDataAdapter
Dim ds As New DataSet
Dim strcon As String = ConfigurationManager.ConnectionStrings("sample").ConnectionString
Dim con As New SqlConnection(strcon)
Dim da As New SqlDataAdapter("Select MenuID, Menus from PagesDetails", con)
Dim dttc As New DataTable()
da.Fill(dttc)
Dim main As HtmlGenericControl = UList("Menuid", "menu")
Dim dtDist As New DataTable()
For Each row As DataRow In dttc.Rows
' For row As Integer = 0 To dttc.Rows.Count - 1
'dtDist.Columns.Clear()
cmd.Parameters.Clear()
dtDist.Clear()
cmd.CommandText = "FindMenus"
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToString(Session("UserId"))
cmd.Parameters.Add("@MenuId", SqlDbType.Int).Value = row("MenuID").ToString()
data.SelectCommand = cmd
data.Fill(dtDist)
If dtDist.Rows.Count > 0 Then
Dim sub_menu As HtmlGenericControl = LIList(row("Menus").ToString(), row("MenuID").ToString())
Dim ul As New HtmlGenericControl("ul")
Dim mains As HtmlGenericControl = UList("SubMenuId", "menu")
For Each r As DataRow In dtDist.Rows
ul.Controls.Add(LIList(r("SubMenu").ToString(), r("SubMenuId").ToString()))
If r IsNot Nothing Then
cmd.Parameters.Clear()
Dim dtsub As New DataTable
Dim data1 As New SqlDataAdapter
cmd.CommandText = "Menusfind"
cmd.Connection = con
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = Convert.ToString(Session("UserId"))
cmd.Parameters.Add("@MenuId", SqlDbType.Int).Value = row("MenuID").ToString()
cmd.Parameters.Add("@SubMenuId", SqlDbType.Int).Value = r("SubMenuId").ToString()
data1.SelectCommand = cmd
data1.Fill(dtsub)
Dim ul1 As New HtmlGenericControl("ul")
Dim sub_menu2 As HtmlGenericControl = LIList(r("SubMenu").ToString(), r("SubMenuId").ToString())
If dtsub.Rows.Count < 0 Then
sub_menu.Controls.Add(ul)
Else
For Each r1 As DataRow In dtsub.Rows
ul1.Controls.Add(LIList(r1("SubMenu2").ToString(), r1("SMenu2Id").ToString()))
Next
sub_menu2.Controls.Add(ul1)
mains.Controls.Add(sub_menu2)
End If
Else
End If
Next
sub_menu.Controls.Add(mains)
'sub_menu.Controls.Add(ul)
main.Controls.Add(sub_menu)
Else
If row("Menus") = "Home" Or row("Menus") = "About" Then
main.Controls.Add(LIList(row("Menus").ToString(), row("Menuid").ToString()))
Else
End If
End If
Next
Panel1.Controls.Add(main)
End Sub
Private Function UList(ByVal id As String, ByVal cssClass As String) As HtmlGenericControl
Dim ul As New HtmlGenericControl("ul")
ul.ID = id
ul.Attributes.Add("class", cssClass)
Return ul
End Function
Private Function LIList(ByVal innerHtml As String, ByVal rel As String) As HtmlGenericControl
Dim li As New HtmlGenericControl("li")
li.Attributes.Add("rel", rel)
li.InnerHtml = (Convert.ToString("<a href=" + ">") & innerHtml) + "</a>"
Return li
End Function
我的Aspx编码喜欢
<head id="Head1" runat="server">
<title>jQuery Simple Dropdown Menu or Menu with Submenu</title>
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
<link rel="stylesheet" href="../../jqwidgets/styles/jqx.summer.css" type="text/css" />
<script type="text/javascript" src="../../scripts/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
<script src="http://code.jquery.com/jquery-1.8.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('.menu ul li').hover(
function () {
$('.sub_menu', this).stop(true, true).slideDown(); /*slideDown the subitems on mouseover*/
}, function () {
$('.sub_menu', this).stop(true, true).slideUp(); /*slideUp the subitems on mouseout*/
});
});
</script>
<style type="text/css">
.menu ul ul {
display: none;
}
.menu ul li:hover > ul {
display: block;
}
.menu ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0 20px;
border-radius: 10px;
list-style: none;
position: relative;
display: inline-table;
}
.menu ul:after {
content: ""; clear: both; display: block;
}
.menu ul li {
float: left;
}
.menu ul li:hover {
background: #4b545f;
background: linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -moz-linear-gradient(top, #4f5964 0%, #5f6975 40%);
background: -webkit-linear-gradient(top, #4f5964 0%,#5f6975 40%);
}
.menu ul li:hover a {
color: #fff;
}
.menu ul li a {
display: block; padding: 25px 40px;
color: #757575; text-decoration: none;
}
.menu ul ul {
background: #5f6975; border-radius: 0px; padding: 0;
position: absolute; top: 100%;
}
.menu ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
.menu ul ul li a {
padding: 15px 40px;
color: #fff;
}
.menu ul ul li a:hover {
background: #4b545f;
}
.menu ul ul ul {
position: absolute; left: 100%; top:0;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div align="left" >
<asp:Label ID="lbl1" runat ="server" ></asp:Label>
</div>
<div align="right" >
<asp:Button ID="login1" Text ="Log Out" runat ="server" />
</div>
<div class="menu">
<asp:Panel ID="Panel1" runat="server">
</asp:Panel>
</div>
</form>
<p>
</p>
</body>
</html>
提前致谢!