ASP.NET 2.0提供了一个Menu 类,可以方便地创建水平或者垂直方向的下拉菜单,下面就是一个例子:
查看例子
1@ Page Language="C#"
1<html>
2<!-- ASP.NET 2.0的例子 -->
3<head runat="server">
4</head>
5<body>
6<form runat="server">
7<h3>下拉菜单的例子</h3>
8<!-- Use declarative syntax to create the -->
9<!-- menu structure. Submenu items are -->
10<!-- created by nesting them in parent menu -->
11<!-- items. -->
12<asp:menu disappearafter="2000" font-names="Arial" id="NavigationMenu" orientation="Horizontal" runat="server" staticdisplaylevels="2" staticsubmenuindent="10" target="_blank">
13<staticmenuitemstyle backcolor="#DDDDDD" forecolor="red"></staticmenuitemstyle>
14<statichoverstyle backcolor="#DDDDDD"></statichoverstyle>
15<dynamicmenuitemstyle backcolor="#EEEEEE" forecolor="red"></dynamicmenuitemstyle>
16<dynamichoverstyle backcolor="#DDDDDD" forecolor="Black"></dynamichoverstyle>
17<items>
18<asp:menuitem navigateurl=" http://dotnet.aspx.cc/ " text="首页" tooltip="首页">
19<asp:menuitem navigateurl=" http://dotnet.aspx.cc/ShowList.aspx?id=1 " text="ASP.NET 栏目" tooltip="ASP.NET 栏目">
20<asp:menuitem navigateurl="Classical.aspx" text="ASP.NET 最新文章" tooltip="ASP.NET 最新文章"></asp:menuitem>
21<asp:menuitem navigateurl="Rock.aspx" text="ASP.NET 问与答" tooltip="ASP.NET 问与答">
22<asp:menuitem navigateurl="Classical.aspx" text="ASP.NET 最新文章" tooltip="ASP.NET 最新文章"></asp:menuitem>
23<asp:menuitem navigateurl="Classical.aspx" text="ASP.NET 最新文章" tooltip="ASP.NET 最新文章"></asp:menuitem>
24</asp:menuitem>
25<asp:menuitem navigateurl="Jazz.aspx" text="Jazz" tooltip="Jazz"></asp:menuitem>
26</asp:menuitem>
27<asp:menuitem navigateurl="Movies.aspx" text="Movies" tooltip="Movies">
28<asp:menuitem navigateurl="Action.aspx" text="Action" tooltip="Action">
29<asp:menuitem navigateurl="Drama.aspx" text="Drama" tooltip="Drama"></asp:menuitem>
30</asp:menuitem>
31<asp:menuitem navigateurl="Drama.aspx" text="Drama" tooltip="Drama"></asp:menuitem>
32<asp:menuitem navigateurl="Musical.aspx" text="Musical" tooltip="Musical"></asp:menuitem>
33</asp:menuitem>
34</asp:menuitem>
35</items>
36</asp:menu>
37</form>
38</body>
39</html>