蓝色信仰

博客园 首页 新随笔 联系 订阅 管理
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();
    }

    
}
posted on 2012-03-07 22:51  蓝色信仰  阅读(239)  评论(0编辑  收藏  举报