Exemple #1
0
            public void InstantiateIn(Control container)
            {
                var li = new WebGenericControl(HtmlTag.Li);
                var ancNavigationItem = new WebAnchor();

                li.Controls.Add(ancNavigationItem);
                container.Controls.Add(li);
            }
Exemple #2
0
            public void InstantiateIn(Control container)
            {
                this.InstantiateInputControls(container);

                var buttonWrapperEnd = new WebPlaceHolder();

                buttonWrapperEnd.InnerHtml = @"</p>";
                container.Controls.Add(buttonWrapperEnd);

                var wrapperEnd = new WebPlaceHolder();

                wrapperEnd.InnerHtml = "</div>";
                container.Controls.Add(wrapperEnd);

                var clearer = new WebGenericControl(HtmlTag.Div);

                clearer.CssClass  = "clearer";
                clearer.InnerHtml = "&nbsp;";
                container.Controls.Add(clearer);
            }
Exemple #3
0
			public void InstantiateIn(Control container) {
				this.InstantiateInputControls(container);

				var buttonWrapperEnd = new WebPlaceHolder();
				buttonWrapperEnd.InnerHtml = @"</p>";
				container.Controls.Add(buttonWrapperEnd);

				var wrapperEnd = new WebPlaceHolder();
				wrapperEnd.InnerHtml = "</div>";
				container.Controls.Add(wrapperEnd);

				var clearer = new WebGenericControl(HtmlTag.Div);
				clearer.CssClass = "clearer";
				clearer.InnerHtml = "&nbsp;";
				container.Controls.Add(clearer);
			}
Exemple #4
0
        public static void PopulateNavigationItem(WebNavigationItemArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            var liClass = string.Empty;
            var aClass  = string.Empty;

            if (args.IsSelected || args.IsInSelectedPath)
            {
                aClass = liClass = args.IsSelected ? "selected" : "selected-path";
            }

            if (args.IsFirstItem)
            {
                liClass = liClass + (liClass.Length > 0 ? " " : string.Empty) + "first-item";
            }
            if (args.IsLastItem)
            {
                liClass = liClass + (liClass.Length > 0 ? " " : string.Empty) + "last-item";
            }
            if (args.IsChildOfRemovedNode)
            {
                liClass = liClass + (liClass.Length > 0 ? " " : string.Empty) + "child-of-removed-node";
            }

            if (args.ParentNavigation.IndicateIfNodeHasChildren)
            {
                var children        = args.ParentNavigation.GetChildren(args.NavigationPage);
                var removedChildren = args.ParentNavigation.IncludeChildrenOfRemovedNodesMode > IncludeChildrenOfRemovedNodesMode.Never ?
                                      new NavigationPageCollection() : null;
                children = args.ParentNavigation.FilterNavigation(children, removedChildren);

                if (args.ParentNavigation.IncludeChildrenOfRemovedNodesMode > IncludeChildrenOfRemovedNodesMode.Never)
                {
                    var nonRemovedDescendants = args.ParentNavigation.GetNonRemovedDescendants(removedChildren);
                    if (args.ParentNavigation.IncludeChildrenOfRemovedNodesMode.Equals(IncludeChildrenOfRemovedNodesMode.OnlyInSelectedPath))
                    {
                        foreach (var descendant in nonRemovedDescendants)
                        {
                            if (args.ParentNavigation.IsPageInSelectedPath(args.ParentNavigation.RootPage, descendant, args.ParentNavigation.SelectedNavigationPage))
                            {
                                children.Add(descendant);
                            }
                        }
                    }
                    else
                    {
                        children.AddRange(nonRemovedDescendants);
                    }
                }
                if (children.Count > 0)
                {
                    liClass = liClass + (liClass.Length > 0 ? " " : string.Empty) + "has-children";
                    aClass  = aClass + (aClass.Length > 0 ? " " : string.Empty) + "has-children";
                }
            }

            var li = args.NavigationItem as WebGenericControl;

            if (liClass.Trim().Length > 0 && li != null)
            {
                li.CssClass = liClass;
            }

            // Find UI Control
            var ancNavigationItem = args.ParentNavigation.GetNavigationAnchorDelegate(args);

            if (ancNavigationItem == null)
            {
                throw new HttpException("The default implementation of PopulateNavigationItem requires at least one WebAnchor inside the ItemTemplate.");
            }
            ancNavigationItem.Visible   = true;
            ancNavigationItem.CssClass += " " + aClass;
            if (string.IsNullOrEmpty(ancNavigationItem.Text))
            {
                ancNavigationItem.Text = args.ParentNavigation.GetNavigationItemNameDelegate(args);
            }
            if (!args.IsSelected || (args.IsSelected && args.ParentNavigation.SelectedPageClickable) || args.ParentNavigation.RootLevelNotClickable)
            {
                if (string.IsNullOrEmpty(ancNavigationItem.NavigateUrl))
                {
                    if (args.ExpandingLevel && args.ParentNavigation.RootLevelNotClickable && args.SubNavigation != null)
                    {
                        args.NavigationItem.ID = HttpUtility.UrlEncode(args.SubNavigation.ClientID.Replace("_", string.Empty) + "Li");
                        if (li != null)
                        {
                            li.RenderId = true;
                        }
                        ancNavigationItem.NavigateUrl = "#" + args.NavigationItem.ID;
                        ancNavigationItem.Attributes.Add("onmousedown", "this.href=this.href+':stop';return true;");
                        ancNavigationItem.Attributes.Add("onclick", "if(this.href.substring(this.href.length - 5,this.href.length)==':stop'){this.href=this.href.substring(0,this.href.length-5);return false;}else{return true;}");
                    }
                    else
                    {
                        ancNavigationItem.NavigateUrl = args.ParentNavigation.GetNavigationItemLinkDelegate(args);
                    }
                }
                if (args.ParentNavigation.AlwaysPlaceSpanAroundNavItem)
                {
                    var gnrNavigationItem = new WebGenericControl("span");
                    args.NavigationItem.Controls.AddAt(0, gnrNavigationItem);
                    gnrNavigationItem.Controls.Add(ancNavigationItem);
                }
                else
                {
                    args.NavigationItem.Controls.AddAt(0, ancNavigationItem);
                }
            }
            else
            {
                ancNavigationItem.InnerSpan = true;
                ancNavigationItem.NoLink    = true;
                args.NavigationItem.Controls.AddAt(0, ancNavigationItem);
            }
        }