Asp.net菜单控件 以前看UCHome进行二次开发的时候,看到他的菜单的实现,是通过数组存储每个菜单的样式。 现在在.NET开发项目时,想采用类似的方法。 Menu.ascx<style type="text/css"> .b{font-weight:bold;} </style> <ul> <li<%=ht["Index"]%>>首页</li> <li<%=ht["News"]%>>公司新闻</li> <li<%=ht["AboutUs"]%>>关于我们</li> </ul> Menu.ascx.cspublic partial class Menu:System.Web.UI.UserControl { protected Hashtable ht = new Hashtable(); public string strStyle = null ; protected void Page_Load(object sender,EventArgs e) { ht[strStyle] = " class=\"b\""; } } Index.aspx<%@ Register Src="~/Controls/Menu.asx" TagPrefix="Lee" TagName="Menu" %><Lee:Menu ID="Menu" runat="server" strStyle="Index"/>