コード例 #1
0
ファイル: MenuItem.cs プロジェクト: wangchunlei/MyGit
		protected virtual string RenderLink()
		{
			CleanTagBuilder anchor = new CleanTagBuilder("a");
			if (ItemDisabled)
				anchor.AddCssClass(DisabledClass);
			else
				anchor.Attributes["href"] = ActionUrl;
			if(IsItemSelected())
				anchor.AddCssClass(SelectedClass);
			anchor.Attributes["title"] = HelpText;
			anchor.InnerHtml += RenderIcon() + RenderTitle();
			return anchor.ToString(TagRenderMode.Normal);
		}
コード例 #2
0
ファイル: MenuItem.cs プロジェクト: wangchunlei/MyGit
		protected virtual string RenderIcon()
		{
			if (!string.IsNullOrEmpty(Icon))
			{
				string iconPath = (IconDirectory ?? "") + Icon;
				CleanTagBuilder icon = new CleanTagBuilder("img");
				icon.Attributes["border"] = "0";
				icon.Attributes["src"] = iconPath;
				icon.Attributes["alt"] = Title;
				icon.AddCssClass(IconClass);
				return icon.ToString(TagRenderMode.SelfClosing);
			}
			return string.Empty;
		}
コード例 #3
0
 protected virtual string RenderIcon()
 {
     if (!string.IsNullOrEmpty(Icon))
     {
         string          iconPath = (IconDirectory ?? "") + Icon;
         CleanTagBuilder icon     = new CleanTagBuilder("img");
         icon.Attributes["border"] = "0";
         icon.Attributes["src"]    = iconPath;
         icon.Attributes["alt"]    = Title;
         icon.AddCssClass(IconClass);
         return(icon.ToString(TagRenderMode.SelfClosing));
     }
     return(string.Empty);
 }
コード例 #4
0
        protected virtual string RenderItems()
        {
            if (items.Count <= 0)
            {
                return(string.Empty);
            }
            CleanTagBuilder ul = new CleanTagBuilder("ul");

            ul.AddCssClass(ListClass);
            foreach (var menuBase in items)
            {
                ul.InnerHtml += menuBase.RenderHtml();
            }
            return(ul.ToString(TagRenderMode.Normal));
        }
コード例 #5
0
        /// <summary>
        /// Used internally to render the menu. Do not call this directly without first calling Prepare, or call RenderHtml(RequestContext ...)
        /// </summary>
        public virtual string RenderHtml()
        {
            if (!Prepared)
            {
                throw new InvalidOperationException("Must call Prepare before RenderHtml() or call RenderHtml(RequestContext, TextWriter)");
            }
            if (HideItem)
            {
                return(string.Empty);
            }
            CleanTagBuilder li = new CleanTagBuilder("li");

            li.AddCssClass(ItemClass);
            li.InnerHtml = RenderLink();
            return(li.ToString(TagRenderMode.Normal));
        }
コード例 #6
0
        protected virtual string RenderLink()
        {
            CleanTagBuilder anchor = new CleanTagBuilder("a");

            if (ItemDisabled)
            {
                anchor.AddCssClass(DisabledClass);
            }
            else
            {
                anchor.Attributes["href"] = ActionUrl;
            }
            if (IsItemSelected())
            {
                anchor.AddCssClass(SelectedClass);
            }
            anchor.Attributes["title"] = HelpText;
            anchor.InnerHtml          += RenderIcon() + RenderTitle();
            return(anchor.ToString(TagRenderMode.Normal));
        }
コード例 #7
0
        public override string RenderHtml()
        {
            if (!Prepared)
            {
                throw new InvalidOperationException("Must call Prepare before RenderHtml(TextWriter) or call RenderHtml(RequestContext, TextWriter)");
            }
            if (HideItem)
            {
                return(string.Empty);
            }
            if (!IsRootList && HasSingleRenderableItem())
            {
                return(items[0].RenderHtml());                //if there is only one item, don't render this menu instead skip to the item
            }
            if (IsRootList)
            {
                return(RenderItems());
            }
            CleanTagBuilder li = new CleanTagBuilder("li");

            li.AddCssClass(ItemClass);
            li.InnerHtml = RenderLink() + RenderItems();
            return(li.ToString(TagRenderMode.Normal));
        }
コード例 #8
0
ファイル: MenuItem.cs プロジェクト: joaofx/mvccontrib
 /// <summary>
 /// Used internally to render the menu. Do not call this directly without first calling Prepare, or call RenderHtml(RequestContext ...)
 /// </summary>
 public virtual string RenderHtml()
 {
     if (!Prepared)
         throw new InvalidOperationException("Must call Prepare before RenderHtml() or call RenderHtml(RequestContext, TextWriter)");
     if (HideItem)
         return string.Empty;
     CleanTagBuilder li = new CleanTagBuilder("li");
     li.AddCssClass(ItemClass);
     li.InnerHtml = RenderLink();
     return li.ToString(TagRenderMode.Normal);
 }