日期:2014-05-17 浏览次数:20573 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected List<Menu> MenuList = new List<Menu>();
protected void Page_Load(object sender, EventArgs e)
{
MenuList.Add(new Menu() { ID = 1, ParentID = 0, Name = "文件" });
MenuList.Add(new Menu() { ID = 2, ParentID = 0, Name = "编辑" });
MenuList.Add(new Menu() { ID = 3, ParentID = 1, Name = "新建" });
MenuList.Add(new Menu() { ID = 4, ParentID = 2, Name = "撤消" });
MenuList.Add(new Menu() { ID = 5, ParentID = 3, Name = "项目" });
MenuList.Add(new Menu() { ID = 6, ParentID = 1, Name = "打开" });
}
}
public class Menu
{
public int ID { get; set; }
public int ParentID { get; set; }
public string Name { get; set; }
}
<!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>
<title></title>
</head>
<body>
<ul>
<li>文件
<ul>
<li>新建
<ul>
<li>项目</li>
</ul>
</li>
<li>打开 </li>
</ul>
</li>
<li>编辑
<ul>
<li>撤消</li>
</ul>
</li>
</ul>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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>
<title></title>
</head>
<body>
<%
for (int i = 0; i <= MenuList.Count - 1; i++)
{
}
//??这里应该如何来输出上面的那个菜单事呢?
//谢谢
%>
</body>
</html>