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


C# HtmlTag.Attr方法代码示例

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

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

示例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;
                            });
        }
开发者ID:marcusswope,项目名称:Hit-That-Line,代码行数:57,代码来源:InputConventions.cs

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

示例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;
        }
开发者ID:rauhryan,项目名称:kokugen,代码行数:27,代码来源:EditInPlaceBuilder.cs

示例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"));
        }
开发者ID:matutee,项目名称:Bardock.Utils,代码行数:16,代码来源:HtmlTagHelperTest.cs

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

示例8: AssertOptionGroup

 private void AssertOptionGroup(
     HtmlTag optgroup,
     string display)
 {
     Assert.Equal("optgroup", optgroup.TagName());
     Assert.Equal(display, optgroup.Attr("label"));
 }
开发者ID:matutee,项目名称:Bardock.Utils,代码行数:7,代码来源:GroupedSelectTagTest.cs

示例9: AddElementName

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

示例10: AddElementName

 public static void AddElementName(ElementRequest request, HtmlTag tag)
 {
     if (tag.IsInputElement())
     {
         tag.Attr(HtmlAttributeConstants.Name, request.ElementId);
     }
 }
开发者ID:phoenixwebgroup,项目名称:Accountability,代码行数:7,代码来源:HtmlConventions.cs

示例11: MarkOptionAsSelected

        private void MarkOptionAsSelected(HtmlTag optionTag)
        {
            var prevSelected = Children.FirstOrDefault(x => x.HasAttr(SelectedAttributeKey));

            prevSelected?.RemoveAttr(SelectedAttributeKey);

            optionTag.Attr(SelectedAttributeKey, SelectedAttributeKey);
        }
开发者ID:calebjenkins,项目名称:htmltags,代码行数:8,代码来源:SelectTag.cs

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

示例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;
        }
开发者ID:randrews,项目名称:dovetail,代码行数:19,代码来源:PizzaTypeEditorConvention.cs

示例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;
		}
开发者ID:NTCoding,项目名称:FubuRaven.NTCoding.com,代码行数:14,代码来源:ViewHelper.cs

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


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