以前看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"/> 相关文章: 2022-12-23 2021-07-24 2021-10-31 2022-01-12 2022-12-23 2022-02-08 2021-12-29