Example #1
0
        private void RenderDropDownMenuItems(DropDownMenuItemCollection items, HtmlTextWriter writer)
        {
            foreach (DropDownMenuItem item in items.FindAll(item => item.Visible))
            {
                string url = GeneralUtils.GetNonEmptyString(item.NavigateUrl, "#");

                if (url != "#" && !url.EndsWith("/") && !url.Contains("?"))
                {
                    string path = HttpContext.Current.Server.MapPath(url);
                    url = (File.Exists(path)) ? ResolveUrl(url) : "#";
                }
                else if (url.Contains("?"))
                {
                    url = ResolveUrl(url);
                }

                writer.WriteBeginTag("li");
                if (!string.IsNullOrEmpty(item.CssClass))
                {
                    writer.WriteAttribute("class", item.CssClass);
                }
                writer.Write(HtmlTextWriter.TagRightChar);

                writer.WriteBeginTag("a");
                writer.WriteAttribute("href", url);
                writer.Write(HtmlTextWriter.TagRightChar);
                writer.Write(item.Text);
                writer.WriteEndTag("a");

                if (item.Items.Count > 0)
                {
                    writer.WriteBeginTag("ul");
                    writer.WriteAttribute("class", "sub_menu");
                    writer.Write(HtmlTextWriter.TagRightChar);

                    RenderDropDownMenuItems(item.Items, writer);

                    writer.WriteEndTag("ul");
                }

                writer.WriteEndTag("li");
            }
        }
Example #2
0
 public DropDownMenuItem()
 {
     Items   = new DropDownMenuItemCollection(this);
     Visible = true;
 }
Example #3
0
 public DropDownMenu()
 {
     Items = new DropDownMenuItemCollection(this);
 }