本文整理汇总了C#中HtmlTag.Attr方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTag.Attr方法的具体用法?C# HtmlTag.Attr怎么用?C# HtmlTag.Attr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTag
的用法示例。
在下文中一共展示了HtmlTag.Attr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Build
public override HtmlTag Build(ElementRequest request)
{
HtmlTag root = new HtmlTag("a");
root.Attr("href", "mailto:" + request.StringValue());
root.Attr("name", request.Accessor.FieldName + "Link");
root.Append(new HtmlTag("span").Text(request.StringValue()));
return root;
}
示例2: AddRangeValidation
private void AddRangeValidation(HtmlTag tag, RangeAttribute range)
{
if (range.Minimum != null)
{
tag.Attr("min", range.Minimum);
}
if (range.Maximum != null)
{
tag.Attr("max", range.Maximum);
}
}
示例3: Build
public override HtmlTag Build(ElementRequest request)
{
HtmlTag root = new HtmlTag("a");
root.Attr("href", request.RawValue);
root.Attr("target", "_blank");
root.Id(request.Accessor.FieldName);
var img = new HtmlTag("img");
img.Attr("src", request.RawValue);
root.Append(img);
return root;
}
示例4: TemplatingDecorators
public static void TemplatingDecorators(QueryToken qt, HtmlTag option)
{
string canIf = CanIf(qt);
if (canIf.HasText())
option.Attr("data-if", canIf);
string canForeach = CanForeach(qt);
if (canForeach.HasText())
option.Attr("data-foreach", canForeach);
string canAny = CanAny(qt);
if (canAny.HasText())
option.Attr("data-any", canAny);
}
示例5: AddElementName
public static void AddElementName(ElementRequest request, HtmlTag tag)
{
if (tag.IsInputElement())
{
tag.Attr("name", DeriveElementName(request));
}
}
示例6: MarkOptionAsSelected
private void MarkOptionAsSelected(HtmlTag optionTag)
{
var prevSelected = Children.FirstOrDefault(x => x.HasAttr(SelectedAttributeKey));
if (prevSelected != null)
{
prevSelected.RemoveAttr(SelectedAttributeKey);
}
optionTag.Attr(SelectedAttributeKey, SelectedAttributeKey);
}
示例7: 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);
}
}
}
示例8: remove_attribute
public void remove_attribute()
{
var tag = new HtmlTag("div");
tag.Attr("foo", "bar");
tag.HasAttr("foo").ShouldBeTrue();
tag.RemoveAttr("foo");
tag.HasAttr("foo").ShouldBeFalse();
}
示例9: attr_can_be_used_to_add_css_class
public void attr_can_be_used_to_add_css_class()
{
var tag = new HtmlTag("a");
tag.Attr("class", "test-class");
tag.HasClass("test-class").ShouldBeTrue();
}
示例10: 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();
}
示例11: 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>");
}
示例12: retrieve_an_empty_attr_should_return_an_empty_string
public void retrieve_an_empty_attr_should_return_an_empty_string()
{
var tag = new HtmlTag("option");
tag.Attr("value", string.Empty);
tag.Attr("value").ShouldEqual(string.Empty);
}
示例13: attr_add_multiple_classes_with_multiple_space_separated_classes
public void attr_add_multiple_classes_with_multiple_space_separated_classes()
{
var tag = new HtmlTag("a");
tag.Attr("class", "test-class1 test-class2 test-class3 test-class4 ");
tag.HasClass("test-class1").ShouldBeTrue();
tag.HasClass("test-class2").ShouldBeTrue();
tag.HasClass("test-class3").ShouldBeTrue();
tag.HasClass("test-class4").ShouldBeTrue();
tag.HasClass(string.Empty).ShouldBeFalse();
}
示例14: AddRangeValidation
private void AddRangeValidation(HtmlTag tag, StringLengthAttribute length)
{
tag.Attr("minlength", length.MinimumLength);
tag.Attr("maxlength", length.MaximumLength);
}
示例15: setting_the_style_attribute_to_null_should_remove_all_styles
public void setting_the_style_attribute_to_null_should_remove_all_styles()
{
var tag = new HtmlTag("div");
tag.Style("padding-left", "20px").Style("padding-right", "30px");
tag.HasStyle("padding-left").ShouldBeTrue();
tag.Attr("style", null);
tag.HasStyle("padding-left").ShouldBeFalse();
}