⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 breadcrumb.cs

📁 ASP.NET精品全站程序SQL版.rar
💻 CS
字号:
namespace ASPNET.StarterKit.Communities {

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;


    //*********************************************************************
    //
    // BreadCrumb Class
    //
    // WebControl that displays a navigation trail.
    //
    //*********************************************************************

    public class BreadCrumb : WebControl {
    

  
        //*********************************************************************
        //
        // SeparatorString Property
        //
        // Represents the characters that appear between the breadcrumb
        // links. By default, a greater than sign >.
        //
        //*********************************************************************
   
        public string SeparatorString {
            get {
                if (ViewState["Separator"] != null)
                    return (string)ViewState["Separator"];
                else
                    return " > ";
            }
            set {
                ViewState["Separator"] = value; 
            }
        }


  
        //*********************************************************************
        //
        // CreateChildControls Method
        //
        // Adds breadcrumb hyperlinks to the Controls collection.
        //
        //*********************************************************************
        
        protected override void CreateChildControls() {
            HyperLink lnkParent;
            
            // Get Section Info from Context
            SectionInfo sectionInfo = (SectionInfo)Context.Items["SectionInfo"];
            
            // Find and add parents
            while (sectionInfo != null) {
                lnkParent = new HyperLink();
                lnkParent.Text = sectionInfo.MenuTitle;
                lnkParent.NavigateUrl = sectionInfo.Path;
                Controls.Add(lnkParent);
                sectionInfo = SectionUtility.GetSectionInfo(sectionInfo.ParentSectionID);
            } 
        
        }

  
        //*********************************************************************
        //
        // RenderContents Method
        //
        // Renders the BreadCrumb control to the browser by iterating
        // through the Controls collection.
        //
        //*********************************************************************
        
        protected override void RenderContents(HtmlTextWriter tw) {
            for (int i = Controls.Count - 1;i > -1;i--) {
                Controls[i].RenderControl(tw);
                if (i > 0)
                    tw.Write( SeparatorString );
            }            
        }


    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -