本文整理汇总了C#中TagBuilder.AddNotEmptyCssClass方法的典型用法代码示例。如果您正苦于以下问题:C# TagBuilder.AddNotEmptyCssClass方法的具体用法?C# TagBuilder.AddNotEmptyCssClass怎么用?C# TagBuilder.AddNotEmptyCssClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TagBuilder
的用法示例。
在下文中一共展示了TagBuilder.AddNotEmptyCssClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public MvcHtmlString Render()
{
var ulTag = new TagBuilder("ul");
ulTag.AddNotEmptyCssClass(CssClass);
ulTag.GenerateId(Id);
ulTag.MergeAttributes(HtmlProperties);
if (Gallery != null && Gallery.Photos != null)
{
var itemNumber = 0;
foreach (var photo in Gallery.Photos)
{
itemNumber++;
var liTag = new TagBuilder("li");
liTag.AddNotEmptyCssClass(ItemCssClass);
if (itemNumber == 1)
{
liTag.AddNotEmptyCssClass(FirstItemCssClass);
}
if (itemNumber == Gallery.Photos.Count)
{
liTag.AddNotEmptyCssClass(LastItemCssClass);
}
var imgCssClass = (photo.Orientation == Orientation.Horizontal ? CssClassLandscape : CssClassPortrait);
var link = Helper.ImageLink(
String.Empty,
VirtualPathUtility.ToAppRelative(photo.ThumbnailSource),
photo.AlternateText,
new { @class = imgCssClass },
String.Empty,
VirtualPathUtility.ToAppRelative(photo.ImageSource),
new { @target = "_blank", @rel = "photo-box" });
liTag.InnerHtml = link.ToHtmlString();
ulTag.InnerHtml += MvcHtmlString.Create(liTag.ToString(TagRenderMode.Normal));
}
}
return MvcHtmlString.Create(ulTag.ToString(TagRenderMode.Normal));
}
示例2: Render
public MvcHtmlString Render()
{
var ulTag = new TagBuilder("ul");
ulTag.AddNotEmptyCssClass(CssClass);
ulTag.GenerateId(Id);
ulTag.MergeAttributes(HtmlProperties);
var itemNumber = 0;
foreach (var item in Menu.Items)
{
itemNumber++;
var liTag = new TagBuilder("li");
liTag.AddNotEmptyCssClass(ItemCssClass);
if (Menu.IsSelected(item))
{
liTag.AddNotEmptyCssClass(SelectedItemCssClass);
}
if (itemNumber == 1)
{
liTag.AddNotEmptyCssClass(FirstItemCssClass);
}
if (itemNumber == Menu.Items.Count)
{
liTag.AddNotEmptyCssClass(LastItemCssClass);
}
if (string.IsNullOrEmpty(item.OnClick))
{
var link = Helper.ActionLink(item.Text, item.Url.ActionName, item.Url.ControllerName ?? string.Empty);
liTag.InnerHtml = link.ToHtmlString();
}
else
{
// see http://stackoverflow.com/questions/134845/href-tag-for-javascript-links-or-javascriptvoid0
liTag.InnerHtml = MvcHtmlString.Create(String.Format("<a onclick=\"{1}\">{0}</a>", item.Text, item.OnClick)).ToHtmlString();
}
ulTag.InnerHtml += MvcHtmlString.Create(liTag.ToString(TagRenderMode.Normal));
}
return MvcHtmlString.Create(ulTag.ToString(TagRenderMode.Normal));
}