private static IHtmlElement CreateBreadcrumpNode(SiteMapNode siteMapNode, Predicate<IHtmlElement> isLastCondition) { var wrapper = new HtmlElement("li") .AddCssClass("toolbar-menu-item") .ToggleCssClass("toolbar-menu-current", element => ReferenceEquals(siteMapNode, System.Web.SiteMap.CurrentNode)); var url = String.IsNullOrEmpty(siteMapNode.Url) ? "javascript:void(0);" : VirtualPathUtility.ToAbsolute(siteMapNode.Url); var anchor = new HtmlElement("a", TagRenderMode.Normal) .Attribute("href", url) .Attribute("title", siteMapNode.Description) .ToggleCssClass("home", element => ReferenceEquals(siteMapNode, System.Web.SiteMap.RootNode)) .ToggleCssClass("last", isLastCondition) .AppendTo(wrapper); if (String.IsNullOrEmpty(siteMapNode.Title)) { anchor.Html(" "); } else { anchor.Text(siteMapNode.Title); } return wrapper; }
private static IHtmlElement CreateMenuNode(IMenuItem node) { var wrapper = new HtmlElement("li") .MergeAttributes(node.HtmlAttributes) .ToggleCssClass("active", element => node.IsSelected); var url = String.IsNullOrEmpty(node.NavigationUri) ? "javascript:void(0);" : VirtualPathUtility.ToAbsolute(node.NavigationUri); var anchor = new HtmlElement("a", TagRenderMode.Normal) .Attribute("href", url) .Attribute("title", node.Description) // .ToggleCssClass("home", element => ReferenceEquals(siteMapNode, System.Web.SiteMap.RootNode)) // .ToggleCssClass("last", isLastCondition) .AppendTo(wrapper); if (String.IsNullOrEmpty(node.Title)) { anchor.Html(" "); } else { anchor.Text(node.Title); } return wrapper; }
public void Should_clear_children_when_setting_text() { IHtmlNode tag = new HtmlElement("div"); tag.Children.Add(new HtmlElement("div")); tag.Text("test"); Assert.Equal(0, tag.Children.Count); }