当前位置: 首页>>代码示例>>C#>>正文


C# HtmlTag.Attr方法代码示例

本文整理汇总了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;
 }
开发者ID:reharik,项目名称:CCHtmlHelpers,代码行数:8,代码来源:EmailDisplayBuilder.cs

示例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);
     }
 }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:11,代码来源:RangeValidationModifier.cs

示例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;
 }
开发者ID:reharik,项目名称:CCHtmlHelpers,代码行数:11,代码来源:ImageFileDisplayBuilder.cs

示例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);
        }
开发者ID:JackWangCUMT,项目名称:extensions,代码行数:14,代码来源:TemplatingClient.cs

示例5: AddElementName

 public static void AddElementName(ElementRequest request, HtmlTag tag)
 {
     if (tag.IsInputElement())
     {
         tag.Attr("name", DeriveElementName(request));
     }
 }
开发者ID:reharik,项目名称:CCHtmlHelpers,代码行数:7,代码来源:CCHtmlConventionsKO.cs

示例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);
        }
开发者ID:reharik,项目名称:CCHtmlHelpers,代码行数:11,代码来源:SelectTag.cs

示例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);
         }
     }
 }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:12,代码来源:ClickToEditModifier.cs

示例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();
        }
开发者ID:ryansroberts,项目名称:htmltags,代码行数:9,代码来源:HtmlTagTester.cs

示例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();
 }
开发者ID:ryansroberts,项目名称:htmltags,代码行数:6,代码来源:HtmlTagTester.cs

示例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();
 }
开发者ID:ryansroberts,项目名称:htmltags,代码行数:9,代码来源:HtmlTagTester.cs

示例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>");
 }
开发者ID:ryansroberts,项目名称:htmltags,代码行数:8,代码来源:HtmlTagTester.cs

示例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);
 }
开发者ID:jv9,项目名称:htmltags,代码行数:6,代码来源:HtmlTagTester.cs

示例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();
 }
开发者ID:jv9,项目名称:htmltags,代码行数:10,代码来源:HtmlTagTester.cs

示例14: AddRangeValidation

 private void AddRangeValidation(HtmlTag tag, StringLengthAttribute length)
 {
     tag.Attr("minlength", length.MinimumLength);
     tag.Attr("maxlength", length.MaximumLength);
 }
开发者ID:phoenixwebgroup,项目名称:DotNetExtensions,代码行数:5,代码来源:StringLengthValidationModifier.cs

示例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();
        }
开发者ID:ryansroberts,项目名称:htmltags,代码行数:10,代码来源:HtmlTagTester.cs


注:本文中的HtmlTag.Attr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。