本文整理汇总了C#中HtmlTags.HtmlTag.AddClass方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTag.AddClass方法的具体用法?C# HtmlTag.AddClass怎么用?C# HtmlTag.AddClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTags.HtmlTag
的用法示例。
在下文中一共展示了HtmlTag.AddClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildLabel
//this is hideous but wanted to show an idea.
public HtmlTag BuildLabel(BehaviorNode behaviorNode)
{
// TODO -- come back and policize this
var span = new HtmlTag("span").AddClass("label");
var pp = behaviorNode.GetType().PrettyPrint();
span.Text("behavior");
if (pp.StartsWith("WebForm"))
{
span.Text("View");
span.AddClass("notice");
}
else if (pp.StartsWith("Call"))
{
span.AddClass("warning");
span.Text("continuation");
}
else if (!behaviorNode.GetType().Name.StartsWith("Fubu"))
{
span.Text("fubu");
}
return span;
}
示例2: AdminForm
public static HtmlString AdminForm(DocumentNode Model, string adminUrl, string divClassName = "")
{
var div = new HtmlTag("div");
if (divClassName != "") div.AddClass(divClassName);
var form = new FormTag().Method("post").Action("#");
form.Append(HtmlBuilder.HtmlTagLabelInput("Name (header)", "name", Model.Name));
form.Append(new HtmlTag("input").Attr("type", "submit").Attr("name", "update").Attr("value", "Update"));
form.Append(HtmlBuilder.HtmlTagLabelCheckbox("Hide header", "hideHeader", Model.HideHeader));
form.Append(HtmlBuilder.HtmlTagLabelTextArea("Body text", "body", Model.Body));
form.Append(HtmlBuilder.HtmlTagLabelTextArea("Extra content 1", "extraContent1", Model.ExtraContent1, 5));
//form.Append(HtmlBuilder.HtmlTagLabelTextArea("Extra content 2", "extraContent2", Model.ExtraContent2, 5));
//form.Append(HtmlBuilder.HtmlTagLabelTextArea("Extra content 3", "extraContent3", Model.ExtraContent3, 3));
form.Append(HtmlBuilder.HtmlTagLabelInput("Author", "author", Model.Author));
form.Append(HtmlBuilder.HtmlTagLabelInput("ViewPath", "viewPath", Model.ViewPath));
form.Append(HtmlBuilder.HtmlTagLabelCheckbox("Hidden", "isHidden", Model.IsHidden));
form.Append(HtmlBuilder.HtmlTagLabelCheckbox("Deleted", "isDeleted", Model.IsDeleted));
form.Append(new HtmlTag("input").Attr("type", "submit").Attr("name", "update").Attr("value", "Update"));
if (!String.IsNullOrEmpty(Model.Url))
{
form.Append(new HtmlTag("p").Append(new HtmlTag("a").Attr("href", Model.Url).Text("View page")));
}
div.Append(form);
return new HtmlString(div.ToHtmlString());
}
示例3: createTags
private static IEnumerable<HtmlTag> createTags(IEnumerable<LogEntry> entries)
{
foreach (LogEntry log in entries)
{
var text = "{0} in {1} milliseconds".ToFormat(log.Description, log.TimeInMilliseconds);
if (!log.Success)
{
text += " -- Failed!";
}
var headerTag = new HtmlTag("h4").Text(text).AddClass("log");
yield return headerTag;
if (log.TraceText.IsNotEmpty())
{
var traceTag = new HtmlTag("pre").AddClass("log").Text(log.TraceText);
if (!log.Success)
{
traceTag.AddClass("failure");
}
yield return traceTag;
}
yield return new HtmlTag("hr");
}
}
示例4: Menu
public static HtmlTag Menu(this IFubuPage page, string menuName = null)
{
var navigationService = page.Get<INavigationService>();
var securityContext = page.Get<ISecurityContext>();
var items = navigationService.MenuFor(new NavigationKey(menuName ?? StringConstants.BlogName));
var menu = new HtmlTag("ul");
items.Each(x =>
{
var link = new LinkTag(x.Key, x.Url);
var li = new HtmlTag("li");
if (x.Key.Equals("Logout") && x.MenuItemState == MenuItemState.Available)
{
var spanTag = new HtmlTag("span");
spanTag.Text(string.Format("Welcome, {0}", securityContext.CurrentIdentity.Name));
menu.Append(spanTag);
}
if (x.MenuItemState == MenuItemState.Active)
li.AddClass("current");
if(x.MenuItemState == MenuItemState.Active || x.MenuItemState == MenuItemState.Available)
menu.Append(li.Append(link));
});
return menu;
}
示例5: Modify
public virtual void Modify(HtmlTag form)
{
if (!_modify) return;
form.Data("validation-mode", _value.ToLower());
form.AddClass("validated-form");
}
示例6: setDisabledState
private static void setDisabledState(MenuItemToken item, HtmlTag link)
{
if (item.MenuItemState == MenuItemState.Disabled)
{
link.AddClass("disabled");
}
}
示例7: WriteResults
public void WriteResults(Counts counts)
{
var countsTag = new HtmlTag("div").AddClass("results");
if (counts.WasSuccessful())
{
countsTag.Text("Succeeded with " + counts.ToString());
countsTag.AddClass("results-" + HtmlClasses.PASS);
}
else
{
countsTag.Text("Failed with " + counts.ToString());
countsTag.AddClass("results-" + HtmlClasses.FAIL);
}
_suiteName.Next = countsTag;
}
示例8: Build
public override HtmlTag Build(ElementRequest request)
{
HtmlTag root = new HtmlTag("div");
root.AddClass("KYT_ListDisplayRoot");
var selectListItems = request.RawValue as IEnumerable<string>;
if (selectListItems == null) return root;
selectListItems.Each(item=> root.Child(new HtmlTag("div").Text(item)));
return root;
}
示例9: InputConventions
public InputConventions()
{
Editors.Always
.Modify((request, tag) => tag.Attr("id", request.Accessor.Name));
Editors
.If(x => x.Accessor.FieldName.Contains("Password") && x.Accessor.PropertyType.IsString())
.Attr("type", "password");
Editors
.If(x => x.Accessor.FieldName.Contains("Email") && x.Accessor.PropertyType.IsString())
.Attr("type", "email");
Editors
.If(x => x.Accessor.FieldName.Contains("Body") && x.Accessor.PropertyType.IsString())
.Modify((r, x) =>
{
x.TagName("textarea");
x.Text(r.StringValue());
});
Editors
.If(x => x.Accessor.InnerProperty.HasAttribute<RequiredAttribute>())
.Modify(x => x.AddClass("required"));
Editors
.If(x => x.Accessor.InnerProperty.HasAttribute<MinLengthAttribute>())
.Modify((request, tag) =>
{
var length = request.Accessor.InnerProperty.GetAttribute<MinLengthAttribute>().Length;
tag.Attr("minlength", length);
});
Editors
.If(x => x.Accessor.InnerProperty.HasAttribute<MaxLengthAttribute>())
.Modify((request, tag) =>
{
var length = request.Accessor.InnerProperty.GetAttribute<MaxLengthAttribute>().Length;
tag.Attr("maxlength", length);
});
Editors.Always
.Modify((request, tag) =>
{
var result = request.Get<IFubuRequest>().Get<ValidationResult>();
if (result == null || result.IsValid) return;
var error = result.Errors.FirstOrDefault(x => x.PropertyName == request.Accessor.InnerProperty.Name);
if (error == null) return;
var errorLabel = new HtmlTag("label");
errorLabel.Text(error.ErrorMessage);
errorLabel.AddClass("error");
errorLabel.Attr("for", request.Accessor.InnerProperty.Name);
errorLabel.Attr("generated", "true");
tag.Next = errorLabel;
});
}
示例10: AddNumberClasses
private static void AddNumberClasses(RequestData r, HtmlTag h)
{
if (r.Accessor.PropertyType == typeof(int) || r.Accessor.PropertyType == typeof(int?)
|| r.Accessor.PropertyType == typeof(uint) || r.Accessor.PropertyType == typeof(uint?)
|| r.Accessor.PropertyType == typeof(long) || r.Accessor.PropertyType == typeof(long?)
|| r.Accessor.PropertyType == typeof(ulong) || r.Accessor.PropertyType == typeof(ulong?)
|| r.Accessor.PropertyType == typeof(short) || r.Accessor.PropertyType == typeof(short?)
|| r.Accessor.PropertyType == typeof(ushort) || r.Accessor.PropertyType == typeof(ushort?))
{
h.AddClass("digits");
}
else if (r.Accessor.PropertyType == typeof(double) || r.Accessor.PropertyType == typeof(double?)
|| r.Accessor.PropertyType == typeof(decimal) || r.Accessor.PropertyType == typeof(decimal?)
|| r.Accessor.PropertyType == typeof(float) || r.Accessor.PropertyType == typeof(float?))
{
h.AddClass("number");
}
}
示例11: FontAwesome
public static HtmlTag FontAwesome(this HtmlHelper htmlHelper, string icon, params string[] options)
{
var tag = new HtmlTag("span").AddClass("fa").AddClass(FAPrefix(icon));
foreach (var item in options)
{
tag.AddClass(FAPrefix(item));
}
return tag;
}
示例12: GetRatingStars
public static HtmlTag GetRatingStars(int rating)
{
var t = new HtmlTag("span");
for (int i = 0; i < rating; i++)
{
var img = new HtmlTag("img");
img.Attr("src", "/Public/images/rating.png");
img.AddClass("ratingImage");
t.Append(img);
}
return t;
}
示例13: writeChildren
private void writeChildren(MenuItemToken item, HtmlTag link)
{
link.AddClass("dropdown-toggle");
link.Attr("data-toggle", "dropdown");
link.Add("b").AddClass("caret");
var ul = Add("ul").AddClass("dropdown-menu");
item.Children.Each(child =>
{
var childTag = new MenuItemTag(child);
ul.Append(childTag);
});
}
示例14: ChildNodes
public static HtmlString ChildNodes(this IDocumentNode IDocumentNode, int atLevel = 0, bool includeHidden = false, bool includeDeleted = false)
{
var ul = new HtmlTags.HtmlTag("ul");
ul.AddClass("topnavigation");
foreach (var c in IDocumentNode.AncestorAtLevel(atLevel).Children.Where(n => (includeDeleted || !n.IsDeleted) && (includeHidden || !n.IsHidden)))
{
var li = new HtmlTags.HtmlTag("li");
if (IDocumentNode.IsDescendantOrSameAs(c)) li.AddClass("selected");
li.Add("a").Attr("href", c.Url).Text(c.Name);
ul.Children.Add(li);
}
return new HtmlString(ul.ToHtmlString());
}
示例15: ChildNodesRecursiveHtmlTag
public static HtmlTag ChildNodesRecursiveHtmlTag(this IDocumentNode currentNode, IDocumentNode IDocumentNode, int allExpandToLevel = 2, bool includeHidden = false, bool includeDeleted = false, string addAdminPath = "")
{
var ul = new HtmlTags.HtmlTag("ul");
foreach (var c in IDocumentNode.Children.Where(n => (includeDeleted || !n.IsDeleted) && (includeHidden || !n.IsHidden)))
{
var li = new HtmlTags.HtmlTag("li");
var path = addAdminPath + c.Url;
li.Add("a").Attr("href", path).Text(c.Name);
if (c == currentNode)
{
li.AddClass("selected");
}
if (c.IsDescendantOrSameAs(currentNode)) li.AddClass("sel");
if (c.Children.Count > 0 && (c.Level < allExpandToLevel || c.IsDescendantOrSameAs(currentNode) || currentNode.IsDescendantOrSameAs(c)))
{
li.Children.Add(ChildNodesRecursiveHtmlTag(currentNode, c, allExpandToLevel, includeHidden, includeDeleted, addAdminPath));
}
ul.Children.Add(li);
}
return ul;
}