Пример #1
0
        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("&nbsp;");
            }
            else
            {
                anchor.Text(siteMapNode.Title);
            }

            return wrapper;
        }
Пример #2
0
        public IHtmlNode Build()
        {
            IHtmlNode datagrid = null;
            IHtmlNode div = new HtmlElement("div")
                .Attribute("id", Component.Id)
                .Attributes(Component.HtmlAttributes);
            IHtmlNode script = new HtmlElement("script");

            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("$('#{0}').datagrid(", Component.Id);

            if (Component.Options.Count > 0 ||
                Component.FrozenColumns.Count > 0 ||
                Component.Columns.Count > 0 ||
                Component.ToolBar.Count > 0)
            {
                builder.Append("{ ");
                builder.Append(string.Format("{0}, {1}{2}{3}",
                    Component.Options.ToDataOptionsString(),
                    ConvertColumnsString(Component.FrozenColumns, "frozenColumns"),
                    ConvertColumnsString(Component.Columns, "columns"),
                    ConvertToolbarString(Component.ToolBar)).TrimStart(',').Trim().TrimEnd(','));
                builder.Append(" }");
            }
            builder.Append(");");

            script.Html(builder.ToString());

            datagrid = new LiteralNode(string.Format("{0}\r\n{1}", div.ToString(), script.ToString()));
            return datagrid;
        }
Пример #3
0
        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("&nbsp;");
            }
            else
            {
                anchor.Text(node.Title);
            }

            return wrapper;
        }