private 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); }
//[Obsolete] //private void CreateControlHierarchyRecursive(ref int index, SiteMapNode node, int parentLevels) //{ // if (parentLevels != 0) // { // SiteMapNode parentNode = node.ParentNode; // if (parentNode != null) // { // this.CreateControlHierarchyRecursive(ref index, parentNode, parentLevels - 1); // this.CreateItem(index++, SiteMapNodeItemType.Parent, node); // } // else // { // this.CreateItem(index++, SiteMapNodeItemType.Root, node); // } // } //} private ResSiteMapNodeItem CreateItem(int itemIndex, Control container, SiteMapNodeItemType itemType, SiteMapNode node) { ResSiteMapNodeItem item = new ResSiteMapNodeItem(itemIndex, itemType); int index = -1; SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item); item.SiteMapNode = node; this.InitializeItem(item); this.OnItemCreated(e); container.Controls.AddAt(index, item); item.DataBind(); this.OnItemDataBound(e); item.SiteMapNode = null; item.EnableViewState = false; return(item); }
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) { HtmlGenericControl iconSpan = null; string iconCss = item.SiteMapNode["iconCss"]; if (string.IsNullOrEmpty(iconCss) == false) { iconSpan = new HtmlGenericControl("span"); iconSpan.Attributes["class"] = iconCss; } HyperLink link = new HyperLink(); item.Attributes["class"] = "list-group-item"; if (itemType == SiteMapNodeItemType.Current) { item.Attributes["class"] += " active"; } link.EnableTheming = false; link.Enabled = this.Enabled; if (string.IsNullOrEmpty(siteMapNode.Url)) { link.NavigateUrl = "javascript:void(0);"; } 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; } } if (iconSpan != null) { link.Controls.Add(iconSpan); link.Controls.Add(new LiteralControl(" ")); } HtmlGenericControl strong = new HtmlGenericControl("strong"); strong.InnerText = siteMapNode.Title; strong.Attributes["class"] = "menu-label"; link.Controls.Add(strong); if (this.ShowToolTips) { link.ToolTip = siteMapNode.Description; } string badgeKey = item.SiteMapNode["badgeKey"]; if (string.IsNullOrEmpty(badgeKey) == false) { var span = new HtmlGenericControl("span"); span.Attributes["class"] = "badge"; span.Attributes["data-badgekey"] = badgeKey; link.Controls.Add(span); } if (item.SiteMapNode.HasChildNodes) { var b = new HtmlGenericControl("b"); b.Attributes["class"] = "arrow icon-angle-down"; link.Controls.Add(b); item.Attributes["role"] = "dropdown-toggle"; } string target = item.SiteMapNode["target"]; if (string.IsNullOrEmpty(target) == false) { link.Target = target; } item.Controls.Add(link); } } else { nodeTemplate.InstantiateIn(item); } }
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) { HtmlGenericControl iconSpan = null; string iconCss = item.SiteMapNode["iconCss"]; if (string.IsNullOrEmpty(iconCss) == false) { iconSpan = new HtmlGenericControl("span"); iconSpan.Attributes["class"] = iconCss; } HyperLink link = new HyperLink(); item.Attributes["class"] = "list-group-item"; if (itemType == SiteMapNodeItemType.Current) item.Attributes["class"] += " active"; link.EnableTheming = false; link.Enabled = this.Enabled; if (string.IsNullOrEmpty(siteMapNode.Url)) { link.NavigateUrl = "javascript:void(0);"; } 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; } } if (iconSpan != null) { link.Controls.Add(iconSpan); link.Controls.Add(new LiteralControl(" ")); } HtmlGenericControl strong = new HtmlGenericControl("strong"); strong.InnerText = siteMapNode.Title; strong.Attributes["class"] = "menu-label"; link.Controls.Add(strong); if (this.ShowToolTips) { link.ToolTip = siteMapNode.Description; } string badgeKey = item.SiteMapNode["badgeKey"]; if (string.IsNullOrEmpty(badgeKey) == false) { var span = new HtmlGenericControl("span"); span.Attributes["class"] = "badge"; span.Attributes["data-badgekey"] = badgeKey; link.Controls.Add(span); } if (item.SiteMapNode.HasChildNodes) { var b = new HtmlGenericControl("b"); b.Attributes["class"] = "arrow icon-angle-down"; link.Controls.Add(b); item.Attributes["role"] = "dropdown-toggle"; } string target = item.SiteMapNode["target"]; if (string.IsNullOrEmpty(target) == false) { link.Target = target; } item.Controls.Add(link); } } else { nodeTemplate.InstantiateIn(item); } }
//[Obsolete] //private void CreateControlHierarchyRecursive(ref int index, SiteMapNode node, int parentLevels) //{ // if (parentLevels != 0) // { // SiteMapNode parentNode = node.ParentNode; // if (parentNode != null) // { // this.CreateControlHierarchyRecursive(ref index, parentNode, parentLevels - 1); // this.CreateItem(index++, SiteMapNodeItemType.Parent, node); // } // else // { // this.CreateItem(index++, SiteMapNodeItemType.Root, node); // } // } //} private ResSiteMapNodeItem CreateItem(int itemIndex, Control container, SiteMapNodeItemType itemType, SiteMapNode node) { ResSiteMapNodeItem item = new ResSiteMapNodeItem(itemIndex, itemType); int index = -1; SiteMapNodeItemEventArgs e = new SiteMapNodeItemEventArgs(item); item.SiteMapNode = node; this.InitializeItem(item); this.OnItemCreated(e); container.Controls.AddAt(index, item); item.DataBind(); this.OnItemDataBound(e); item.SiteMapNode = null; item.EnableViewState = false; return item; }
private 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; }
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 (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); } }
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 (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); } }