本文整理汇总了C#中HtmlTags.HtmlTag.Attr方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTag.Attr方法的具体用法?C# HtmlTag.Attr怎么用?C# HtmlTag.Attr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTags.HtmlTag
的用法示例。
在下文中一共展示了HtmlTag.Attr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddElementName
public static void AddElementName(ElementRequest request, HtmlTag tag)
{
if (tag.IsInputElement())
{
tag.Attr("name", request.ElementId);
tag.Attr("id", idRegex.Replace(request.ElementId, "_"));
}
}
示例2: 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;
}
示例3: 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;
});
}
示例4: 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;
}
示例5: Build
public override HtmlTag Build(ElementRequest request)
{
var tag = new HtmlTag("div").Text(request.StringValue()).AddClass("editable").Id(request.Accessor.Name);
var options = new EditOptions();
if (request.Accessor.HasAttribute<MarkdownAttribute>())
{
tag.UnEncoded().Text(new Markdown().Transform(request.RawValue== null ? "" : request.RawValue.ToString()));
options.Markdown = true;
}
options.MultiLine = request.Accessor.Name == "Details";
options.RequiresExplicitUserActionForSave = true;
options.MaximumLength = request.Accessor.PropertyType.Equals(typeof(string)) ? Entity.UnboundedStringLength : 0;
options.IsDate = request.Accessor.PropertyType.IsDateTime();
options.IsTime = request.Accessor.Name.ToLower().Contains("time");
options.IsNumber = request.Accessor.PropertyType.IsIntegerBased() || request.Accessor.PropertyType.IsFloatingPoint();
options.Required = request.Accessor.HasAttribute<RequiredAttribute>();
options.PlaceholderText = "Double-Click to edit " + request.Accessor.Name.ToLower() + ".";
var data = options.ToJson();
tag.Attr("data", "{editoptions:"+data+"}");
return tag;
}
示例6: AssertValid
public void AssertValid(HtmlTag tag, string tagName, string name, string type = "", object value = null)
{
Assert.Equal(tagName, tag.TagName());
Assert.Equal(name, tag.Attr("name"));
Assert.Equal(name, tag.Attr("id"));
if (type == null)
Assert.False(tag.HasAttr("type"));
else
Assert.Equal(type, tag.Attr("type"));
if (value == null)
Assert.True(!tag.HasAttr("value") || tag.Attr("value") == "");
else
Assert.Equal(value.ToString(), tag.Attr("value"));
}
示例7: Build
public override HtmlTag Build(ElementRequest request)
{
HtmlTag root = new HtmlTag("a");
root.Attr("data-bind", "attr: { href: mailto:" + CCHtmlConventionsKO.DeriveElementName(request)+"}");
root.Children.Add(new HtmlTag("span").Attr("data-bind", "text:" + CCHtmlConventionsKO.DeriveElementName(request)));
return root;
}
示例8: AssertOptionGroup
private void AssertOptionGroup(
HtmlTag optgroup,
string display)
{
Assert.Equal("optgroup", optgroup.TagName());
Assert.Equal(display, optgroup.Attr("label"));
}
示例9: AddElementName
public static void AddElementName(ElementRequest request, HtmlTag tag)
{
if (tag.IsInputElement())
{
tag.Attr("name", request.ElementId);
}
}
示例10: AddElementName
public static void AddElementName(ElementRequest request, HtmlTag tag)
{
if (tag.IsInputElement())
{
tag.Attr(HtmlAttributeConstants.Name, request.ElementId);
}
}
示例11: MarkOptionAsSelected
private void MarkOptionAsSelected(HtmlTag optionTag)
{
var prevSelected = Children.FirstOrDefault(x => x.HasAttr(SelectedAttributeKey));
prevSelected?.RemoveAttr(SelectedAttributeKey);
optionTag.Attr(SelectedAttributeKey, SelectedAttributeKey);
}
示例12: getLiItem
private HtmlTag getLiItem(MenuItem item)
{
if (item == null) return null;
var li = new HtmlTag("li");
if(item.CssClass.IsNotEmpty())
li.AddClass(item.CssClass);
var anchor = new HtmlTag("a");
anchor.Attr("href", "#");
anchor.Attr("rel", item.Url);
anchor.Text(item.Text);
li.Children.Add(anchor);
if(item.Children!=null)
{
var ul = new HtmlTag("ul");
renderListItems(ul, item.Children);
li.Children.Add(ul);
}
return li;
}
示例13: Build
public override HtmlTags.HtmlTag Build(ElementRequest request)
{
HtmlTag el = new HtmlTag("ul").AddClass("pizza-type");
IRepository repository = request.Get<IRepository>();
IEnumerable<PizzaType> pizzaTypes = repository.GetAll<PizzaType>().Cast<PizzaType>();
var stringifier = request.Get<Stringifier>();
foreach (PizzaType pt in pizzaTypes)
{
HtmlTag radio = new HtmlTag("input");
radio.Attr("type", "radio").Attr("name", "PizzaType");
radio.Attr("value", pt.Id);
radio.Text(stringifier.GetString(pt));
el.Append(new HtmlTag("li").Append(radio));
}
return el;
}
示例14: 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;
}
示例15: 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);
});
}