<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Menu.aspx.cs" Inherits="Menu" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Menu ID="Menu1" runat="server" BorderStyle="None" Orientation="Horizontal">
</asp:Menu>
</div>
</form>
</body>
</html>
代码好简单,其实就是不段写code添加,看来还是比较方便.. 就是样式还没有弄懂
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Menu : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
MenuItem mi1 = new MenuItem();
MenuItem mi2 = new MenuItem();
MenuItem mi3 = new MenuItem();
mi1.Text = "aa";
mi2.Text = "bb";
mi3.Text = "cc";
mi2.ChildItems.Add(mi3);
mi1.ChildItems.Add(mi2);
Menu1.Items.Add(mi1);
MenuItem mi11 = new MenuItem();
MenuItem mi12 = new MenuItem();
MenuItem mi13 = new MenuItem();
mi11.Text = "aa";
mi12.Text = "bb";
mi13.Text = "cc";
mi12.ChildItems.Add(mi13);
mi11.ChildItems.Add(mi12);
Menu1.Items.Add(mi11);
}
}
}