using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class UserControls_UCSiteMapPath : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } protected void SiteMapPath1_ItemDataBound(object sender, SiteMapNodeItemEventArgs e) { var item = e.Item; if (item.ItemType == SiteMapNodeItemType.Current && item.SiteMapNode.Description == "查看商品详细") { var category = Category.GetProductCategory(new Guid(Request["ID"]));//商品的直接类别 e.Item.Controls.AddAt(0, new HyperLink() { Text = category.Name, NavigateUrl = string.Format("~/ProductsByCategory.aspx?CategoryID={0}", category.ID) }); e.Item.Controls.AddAt(0, new Literal() { Text = this.SiteMapPath1.PathSeparator }); Category.BuildSiteMapPath(e, category, this.SiteMapPath1.PathSeparator); string titlename, name; if (this.Page is PageBase) { titlename = (this.Page as PageBase).PageTitle; name = titlename.Substring(6, titlename.Length-6); e.Item.Controls.AddAt(0, new HyperLink() { Text = name, NavigateUrl = "~/" }); e.Item.Controls.AddAt(0, new Literal() { Text = this.SiteMapPath1.PathSeparator }); } } string s = item.ToString(); } }