예제 #1
0
        protected ResSiteMapNodeItem CreateItem(int itemIndex, SiteMapNodeItemType itemType, SiteMapNode node)
        {
            ResSiteMapNodeItem item = new ResSiteMapNodeItem(itemIndex, itemType);
            int index = (this.PathDirection == PathDirection.CurrentToRoot) ? 0 : -1;
            SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item);

            item.SiteMapNode = node;
            this.InitializeItem(item);
            this.OnItemCreated(e);
            this.Controls.AddAt(index, item);
            item.DataBind();
            this.OnItemDataBound(e);
            item.SiteMapNode     = null;
            item.EnableViewState = false;

            return(item);
        }
예제 #2
0
        protected ResSiteMapNodeItem CreateItem(int itemIndex, SiteMapNodeItemType itemType, SiteMapNode node)
        {
            ResSiteMapNodeItem item = new ResSiteMapNodeItem(itemIndex, itemType);
            int index = (this.PathDirection == PathDirection.CurrentToRoot) ? 0 : -1;
            SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item);
            item.SiteMapNode = node;
            this.InitializeItem(item);
            this.OnItemCreated(e);
            this.Controls.AddAt(index, item);
            item.DataBind();
            this.OnItemDataBound(e);
            item.SiteMapNode = null;
            item.EnableViewState = false;

            return item;
        }
예제 #3
0
        protected virtual void InitializeItem(ResSiteMapNodeItem item)
        {
            ITemplate           nodeTemplate = null;
            SiteMapNodeItemType itemType     = item.ItemType;
            SiteMapNode         siteMapNode  = item.SiteMapNode;

            switch (itemType)
            {
            case SiteMapNodeItemType.Root:
                nodeTemplate = (this.RootNodeTemplate != null) ? this.RootNodeTemplate : this.NodeTemplate;
                break;

            case SiteMapNodeItemType.Parent:
                nodeTemplate = this.NodeTemplate;
                break;

            case SiteMapNodeItemType.Current:
                nodeTemplate = (this.CurrentNodeTemplate != null) ? this.CurrentNodeTemplate : this.NodeTemplate;
                break;
            }

            if (nodeTemplate == null)
            {
                if (itemType != SiteMapNodeItemType.PathSeparator)
                {
                    if (itemType == SiteMapNodeItemType.Current)
                    {
                        item.Attributes["class"] = "active";
                    }

                    if ((itemType == SiteMapNodeItemType.Current) && !this.RenderCurrentNodeAsLink)
                    {
                        Literal literal2 = new Literal
                        {
                            Mode = LiteralMode.Encode,
                            Text = siteMapNode.Title
                        };

                        item.Controls.Add(literal2);
                    }
                    else
                    {
                        if (itemType == SiteMapNodeItemType.Root)
                        {
                            item.Controls.Add(new LiteralControl("<i class=\"icon-home\"></i> "));
                        }

                        HyperLink link = new HyperLink();

                        link.EnableTheming = false;
                        link.Enabled       = this.Enabled;

                        if (string.IsNullOrEmpty(siteMapNode.Url))
                        {
                            link.NavigateUrl = "javascript:void(0);";
                            link.Enabled     = false;
                        }
                        else if (siteMapNode.Url.StartsWith(@"\\", StringComparison.Ordinal))
                        {
                            link.NavigateUrl = base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url));
                        }
                        else
                        {
                            link.NavigateUrl = (this.Context != null) ? this.Context.Response.ApplyAppPathModifier(base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url))) : siteMapNode.Url;
                        }
                        link.Text = HttpUtility.HtmlEncode(siteMapNode.Title);
                        if (this.ShowToolTips)
                        {
                            link.ToolTip = siteMapNode.Description;
                        }

                        item.Controls.Add(link);
                    }
                }
            }
            else
            {
                nodeTemplate.InstantiateIn(item);
            }
        }
예제 #4
0
        protected virtual void InitializeItem(ResSiteMapNodeItem item)
        {
            ITemplate nodeTemplate = null;
            SiteMapNodeItemType itemType = item.ItemType;
            SiteMapNode siteMapNode = item.SiteMapNode;
            switch (itemType)
            {
                case SiteMapNodeItemType.Root:
                    nodeTemplate = (this.RootNodeTemplate != null) ? this.RootNodeTemplate : this.NodeTemplate;
                    break;

                case SiteMapNodeItemType.Parent:
                    nodeTemplate = this.NodeTemplate;
                    break;

                case SiteMapNodeItemType.Current:
                    nodeTemplate = (this.CurrentNodeTemplate != null) ? this.CurrentNodeTemplate : this.NodeTemplate;
                    break;
            }

            if (nodeTemplate == null)
            {
                if (itemType != SiteMapNodeItemType.PathSeparator)
                {
                    if (itemType == SiteMapNodeItemType.Current)
                        item.Attributes["class"] = "active";

                    if ((itemType == SiteMapNodeItemType.Current) && !this.RenderCurrentNodeAsLink)
                    {
                        Literal literal2 = new Literal
                        {
                            Mode = LiteralMode.Encode,
                            Text = siteMapNode.Title
                        };

                        item.Controls.Add(literal2);
                    }
                    else
                    {
                        if (itemType == SiteMapNodeItemType.Root)
                        {
                            item.Controls.Add(new LiteralControl("<i class=\"icon-home\"></i> "));

                        }

                        HyperLink link = new HyperLink();

                        link.EnableTheming = false;
                        link.Enabled = this.Enabled;

                        if (string.IsNullOrEmpty(siteMapNode.Url))
                        {
                            link.NavigateUrl = "javascript:void(0);";
                            link.Enabled = false;
                        }
                        else if (siteMapNode.Url.StartsWith(@"\\", StringComparison.Ordinal))
                        {
                            link.NavigateUrl = base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url));
                        }
                        else
                        {
                            link.NavigateUrl = (this.Context != null) ? this.Context.Response.ApplyAppPathModifier(base.ResolveClientUrl(HttpUtility.UrlPathEncode(siteMapNode.Url))) : siteMapNode.Url;
                        }
                        link.Text = HttpUtility.HtmlEncode(siteMapNode.Title);
                        if (this.ShowToolTips)
                        {
                            link.ToolTip = siteMapNode.Description;
                        }

                        item.Controls.Add(link);
                    }
                }
            }
            else
            {
                nodeTemplate.InstantiateIn(item);
            }
        }