本文整理汇总了C#中HtmlTag.AddClass方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTag.AddClass方法的具体用法?C# HtmlTag.AddClass怎么用?C# HtmlTag.AddClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTag
的用法示例。
在下文中一共展示了HtmlTag.AddClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CellTag
public IHtmlNode CellTag(DateTime day, string urlFormat, bool isOtherMonth)
{
IHtmlNode cell = new HtmlTag("td");
if (isOtherMonth)
{
cell.AddClass("t-other-month");
}
else if(Calendar.Value != null && day.Day == Calendar.Value.Value.Day)
{
cell.AddClass(UIPrimitives.SelectedState);
}
if (Calendar.IsDateInRange(day))
{
var href = GetUrl(day, urlFormat);
IHtmlNode link = new HtmlTag("a")
.AddClass(UIPrimitives.Link + (href != "#" ? " t-action-link" : string.Empty))
.Attribute("href", href)
.Text(day.Day.ToString());
cell.Children.Add(link);
}
else
{
cell.Html(" ");
}
return cell;
}
示例2: render_a_single_class_even_though_it_is_registered_more_than_once
public void render_a_single_class_even_though_it_is_registered_more_than_once()
{
HtmlTag tag = new HtmlTag("div").Text("text");
tag.AddClass("a");
tag.ToCompacted().ShouldEqual("<div class=\"a\">text</div>");
tag.AddClass("a");
tag.ToCompacted().ShouldEqual("<div class=\"a\">text</div>");
}
示例3: do_not_allow_spaces_in_class_names
public void do_not_allow_spaces_in_class_names()
{
HtmlTag tag = new HtmlTag("div").Text("text");
typeof(ArgumentException).ShouldBeThrownBy(() =>
{
tag.AddClass("a b c");
});
}
示例4: ClickToEdit
public static void ClickToEdit(ElementRequest request, HtmlTag tag)
{
if (tag.IsInputElement())
{
var clickToEdit = request.Accessor.GetAttribute<ClickToEditAttribute>();
tag.AddClass("clickToEdit");
if (!string.IsNullOrEmpty(clickToEdit.Action))
{
tag.Attr("ClickToEditAction", clickToEdit.Action);
}
}
}
示例5: BuildCore
protected override IHtmlNode BuildCore()
{
var li = new HtmlTag("li");
if (tool.Template.HasValue())
{
li.AddClass(UIPrimitives.Editor.Custom);
tool.Template.Apply(li);
}
else
{
li.AddClass(UIPrimitives.Editor.ToolbarButton);
var a = new HtmlTag("a")
.Attributes(tool.HtmlAttributes)
.Attribute("href", "#")
.AddClass(UIPrimitives.Editor.ToolIcon);
a.AppendTo(li);
}
return li;
}
示例6: set_the_class_attribute_to_null_should_remove_all_classes
public void set_the_class_attribute_to_null_should_remove_all_classes()
{
var tag = new HtmlTag("div");
tag.AddClass("first");
tag.AddClass("second");
tag.Attr("class", null);
tag.ToString().ShouldEqual("<div></div>");
}
示例7: render_multiple_classes
public void render_multiple_classes()
{
var tag = new HtmlTag("div").Text("text");
tag.AddClass("a");
tag.AddClass("b");
tag.AddClass("c");
tag.ToString().ShouldEqual("<div class=\"a b c\">text</div>");
}
示例8: attr_add_multiple_classes_with_space_separated_classes
public void attr_add_multiple_classes_with_space_separated_classes()
{
var tag = new HtmlTag("a");
tag.AddClass("added-class");
tag.Attr("class", "test-class1 test-class2");
tag.HasClass("added-class").ShouldBeTrue();
tag.HasClass("test-class1").ShouldBeTrue();
tag.HasClass("test-class2").ShouldBeTrue();
}
示例9: add_a_class
public void add_a_class()
{
var tag = new HtmlTag("div");
tag.AddClass("a");
tag.ToString().ShouldEqual("<div class=\"a\"></div>");
}
示例10: add_multiple_classes_at_once_with_multiple_spaces
public void add_multiple_classes_at_once_with_multiple_spaces()
{
var tag = new HtmlTag("div").Text("text");
tag.AddClass("a b c d e ");
tag.ToString().ShouldEqual("<div class=\"a b c d e\">text</div>");
}
示例11: NavigationLink
private IHtmlNode NavigationLink(string direction, DateTime? focusedDate, bool isDisabled)
{
IHtmlNode link = new HtmlTag("a")
.Attribute("href", "#")
.AddClass(UIPrimitives.Link, "t-nav-" + direction);
if (isDisabled)
link.AddClass("t-state-disabled");
if (direction == CalendarNavigation.Fast)
{
link.Text(focusedDate.Value.ToString("MMMM yyyy"));
}
else
{
link.Children.Add(new HtmlTag("span")
.AddClass(UIPrimitives.Icon, "t-arrow-" + direction));
}
return link;
}
示例12: class_name_must_have_at_least_two_chars_if_starts_with_dash
public void class_name_must_have_at_least_two_chars_if_starts_with_dash()
{
var tag = new HtmlTag("div").Text("text");
typeof(ArgumentException).ShouldBeThrownBy(() => { tag.AddClass("-"); });
}
示例13: should_report_has_class_attribute_if_any_classes_added
public void should_report_has_class_attribute_if_any_classes_added()
{
var tag = new HtmlTag("div");
tag.HasAttr("class").ShouldBeFalse();
tag.AddClass("first");
tag.HasAttr("class").ShouldBeTrue();
}
示例14: valid_class_names
public void valid_class_names()
{
var tag = new HtmlTag("div").Text("text");
tag.AddClass("-test");
tag.ToString().ShouldEqual("<div class=\"-test\">text</div>");
tag.AddClass("_test");
tag.ToString().ShouldEqual("<div class=\"-test _test\">text</div>");
tag.AddClass("TEST_2-test");
tag.ToString().ShouldEqual("<div class=\"-test _test TEST_2-test\">text</div>");
tag.AddClass("-just-4-test");
tag.ToString().ShouldEqual("<div class=\"-test _test TEST_2-test -just-4-test\">text</div>");
}
示例15: do_not_allow_start_with_number_in_class_names
public void do_not_allow_start_with_number_in_class_names()
{
var tag = new HtmlTag("div").Text("text");
typeof(ArgumentException).ShouldBeThrownBy(() => { tag.AddClass("4test"); });
}