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


C# TagHelperOutput.AddCssClass方法代码示例

本文整理汇总了C#中Microsoft.AspNet.Razor.TagHelpers.TagHelperOutput.AddCssClass方法的典型用法代码示例。如果您正苦于以下问题:C# TagHelperOutput.AddCssClass方法的具体用法?C# TagHelperOutput.AddCssClass怎么用?C# TagHelperOutput.AddCssClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.AspNet.Razor.TagHelpers.TagHelperOutput的用法示例。


在下文中一共展示了TagHelperOutput.AddCssClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProcessNonCheckControl

 private void ProcessNonCheckControl(TagHelperOutput output) {
     output.AddCssClass("form-control");
     if (!string.IsNullOrEmpty(PostAddonText) || !string.IsNullOrEmpty(PreAddonText)) {
         if ((Size ?? BootstrapTagHelpers.Size.Default) != BootstrapTagHelpers.Size.Default) {
             Size size = Size == BootstrapTagHelpers.Size.Large
                             ? BootstrapTagHelpers.Size.Large
                             : BootstrapTagHelpers.Size.Small;
             output.PreElement.PrependHtml($"<div class=\"input-group input-group-{size.GetDescription()}\">");
         }
         else
             output.PreElement.PrependHtml("<div class=\"input-group\">");
         if (!string.IsNullOrEmpty(PreAddonText))
             output.PreElement.AppendHtml(AddonTagHelper.GenerateAddon(PreAddonText));
         if (!string.IsNullOrEmpty(PostAddonText))
             output.PostElement.AppendHtml(AddonTagHelper.GenerateAddon(PostAddonText));
         output.PostElement.AppendHtml("</div>");
     }
     else if (Size != null && Size != BootstrapTagHelpers.Size.Default)
         output.AddCssClass("input-" + Size.Value.GetDescription());
     if (!string.IsNullOrEmpty(HelpText))
         if (InputGroupContext != null)
             InputGroupContext.Output.PostElement.PrependHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText));
         else
             output.PostElement.AppendHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText));
     if (InputGroupContext==null)
     if (FormGroupContext != null)
         FormGroupContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label));
     else if (FormContext != null)
         FormContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label));
     if (!string.IsNullOrEmpty(Label))
         if (InputGroupContext == null)
             output.PreElement.Prepend(LabelTagHelper.GenerateLabel(Label, Id, FormContext));
         else
             InputGroupContext.Output.PreElement.Prepend(LabelTagHelper.GenerateLabel(Label, Id,
                                                                                      FormContext));
     if (FormGroupContext != null && FormGroupContext.HasFeedback &&
         FormGroupContext.ValidationContext != null) {
         string cssClass;
         string srText;
         switch (FormGroupContext.ValidationContext.Value) {
             case ValidationContext.Success:
                 cssClass = "ok";
                 srText = Ressources.ValidationSuccess;
                 break;
             case ValidationContext.Warning:
                 cssClass = "warning-sign";
                 srText = Ressources.ValidationWarning;
                 break;
             case ValidationContext.Error:
                 cssClass = "remove";
                 srText = Ressources.ValidationError;
                 break;
             default:
                 throw new ArgumentOutOfRangeException();
         }
         output.PostElement.PrependHtml(
                                        $"<span class=\"glyphicon glyphicon-{cssClass} form-control-feedback\" aria-hidden=\"true\"></span>");
         output.PostElement.PrependHtml($"<span class=\"sr-only\">({srText})</span>");
     }
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:60,代码来源:InputTagHelper.cs

示例2: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     if (Format == null)
         Format = Configuration.ResponsiveEmbedFormat;
     output.TagName = "div";
     output.AddCssClass("embed-responsive");
     output.AddCssClass("embed-responsive-" + Format.Value.GetDescription());
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:7,代码来源:ResponsiveEmbedTagHelper.cs

示例3: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     context.SetButtonGroupContext(this);
     output.Attributes.Add("role", "group");
     if (context.HasInputGroupContext())
     {
         Size = BootstrapTagHelpers.Size.Default;
         if (!context.HasInputGroupAddonContext())
         {
             output.TagName = "span";
             output.AddCssClass("input-group-btn");
         }
         context.RemoveInputGroupContext();
     }
     else {
         output.TagName = "div";
         if (Vertical)
             output.AddCssClass("btn-group-vertical");
         else
             output.AddCssClass("btn-group");
         if (Size.HasValue)
             output.AddCssClass("btn-group-" + Size.Value.GetDescription());
         if (Justified)
             output.AddCssClass("btn-group-justified");
     }
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:25,代码来源:ButtonGroupTagHelper.cs

示例4: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     output.TagName = "ul";
     output.AddCssClass("nav");
     output.AddCssClass("nav-tabs");
     if (Justified)
         output.AddCssClass("nav-justified");
     context.SetNavContext(this);
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:8,代码来源:NavTabsTagHelper.cs

示例5: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     output.TagName = "div";
     output.AddCssClass("panel");
     output.AddCssClass("panel-" + Context.ToString().ToLower());
     if (!string.IsNullOrEmpty(Heading))
         output.PreContent.PrependHtml($"<div class=\"panel-heading\">{Heading}</div>");
     if (!string.IsNullOrEmpty(Footer))
         output.PostContent.AppendHtml($"<div class=\"panel-footer\">{Footer}</div>");
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:9,代码来源:PanelTagHelper.cs

示例6: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     output.TagName = "div";
     output.AddCssClass("form-group");
     if (ValidationContext.HasValue)
         output.AddCssClass("has-" + ValidationContext.Value.ToString().ToLower());
     if (HasFeedback)
         output.AddCssClass("has-feedback");
     if (Size != null && Size != SimpleSize.Default)
         output.AddCssClass("form-group-" + Size.Value.GetDescription());
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:10,代码来源:FormGroupTagHelper.cs

示例7: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     if (Rounded)
         output.AddCssClass("img-rounded");
     if (Circle)
         output.AddCssClass("img-circle");
     if (Thumbnail)
         output.AddCssClass("img-thumbnail");
     if (Responsive)
         output.AddCssClass("img-responsive");
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:10,代码来源:ImgTagHelper.cs

示例8: RenderOutput

 protected virtual void RenderOutput(TagHelperOutput output) {
     output.TagName = GetTagName();
     output.AddCssClass("list-group-item");
     if (!string.IsNullOrEmpty(BadgeText))
         output.PreContent.PrependHtml($"<span class=\"badge\">{BadgeText}</span>");
     if (Context != null)
         output.AddCssClass("list-group-item-" + Context.ToString().ToLower());
     if (Active)
         output.AddCssClass("active");
     if (Disabled)
         output.AddCssClass("disabled");
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:12,代码来源:ListGroupItemTagHelper.cs

示例9: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     output.AddCssClass("form-control");
     if (FormGroupContext != null)
         FormGroupContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label));
     else if (FormContext != null)
         FormContext.WrapInDivForHorizontalForm(output, !string.IsNullOrEmpty(Label));
     if (!string.IsNullOrEmpty(Label))
         output.PreElement.Prepend(LabelTagHelper.GenerateLabel(Label, FormContext));
     if (!string.IsNullOrEmpty(HelpText))
             output.PostElement.PrependHtml(HelpBlockTagHelper.GenerateHelpBlock(HelpText));
     if (Size != null && Size != BootstrapTagHelpers.Size.Default)
         output.AddCssClass("input-" + Size.Value.GetDescription());
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:13,代码来源:SelectTagHelper.cs

示例10: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     output.TagName = "li";
     output.Attributes.Add("role", "presentation");
     if (Disabled) {
         output.AddCssClass("disabled");
         output.PreContent.PrependHtml($"<a data-href=\"{Href}\">");
     }
     else
         output.PreContent.PrependHtml($"<a href=\"{Href}\">");
     output.PostContent.AppendHtml("</a>");
     if (Active)
         output.AddCssClass("active");
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:13,代码来源:NavItemTagHelper.cs

示例11: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     output.TagName = "div";
     if (FormContext?.Horizontal ?? true) {
         if ((WidthLg ?? 0) > 0) {
             output.AddCssClass("col-lg-" + WidthLg);
             if (SetOffset ?? false)
                 output.AddCssClass("col-lg-offset-" + (12 - WidthLg));
         }
         if ((WidthMd ?? 0) > 0) {
             output.AddCssClass("col-md-" + WidthMd);
             if (SetOffset ?? false)
                 output.AddCssClass("col-md-offset-" + (12 - WidthMd));
         }
         if ((WidthSm ?? 0) > 0) {
             output.AddCssClass("col-sm-" + WidthSm);
             if (SetOffset ?? false)
                 output.AddCssClass("col-sm-offset-" + (12 - WidthSm));
         }
         if ((WidthXs ?? 0) > 0) {
             output.AddCssClass("col-xs-" + WidthXs);
             if (SetOffset ?? false)
                 output.AddCssClass("col-xs-offset-" + (12 - WidthXs));
         }
     }
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:25,代码来源:HorizontalFormContainerTagHelper.cs

示例12: BootstrapProcessAsync

        protected override async Task BootstrapProcessAsync(TagHelperContext context, TagHelperOutput output) {
            output.TagName = "div";
            output.AddCssClass("alert");
            output.AddCssClass("alert-" + Context.ToString().ToLower());
            output.Attributes.Add("role", "attribute");
            if (Dismissable)
                output.PreContent.SetHtmlContent(
                                                 $"<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"{Ressources.CloseIconText}\"><span aria-hidden=\"true\">&times;</span></button>");
            if (!DisableLinkStyling) {
                var content = await output.GetChildContentAsync(true);
                output.Content.SetHtmlContent(Regex.Replace(content.GetContent(), "<a( [^>]+)?>", AddLinkStyle));
            }

        }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:14,代码来源:AlertTagHelper.cs

示例13: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     if (HiddenXs)
         output.AddCssClass("hidden-xs");
     if (HiddenSm)
         output.AddCssClass("hidden-sm");
     if (HiddenMd)
         output.AddCssClass("hidden-md");
     if (HiddenLg)
         output.AddCssClass("hidden-lg");
     if (HiddenPrint)
         output.AddCssClass("hidden-print");
     if (SrOnly || SrOnlyFocusable)
         output.AddCssClass("sr-only");
     if (SrOnlyFocusable)
         output.AddCssClass("sr-only-focusable");
     if (VisibleXs != null)
         output.AddCssClass("visible-xs-" + VisibleXs.Value.GetDescription());
     if (VisibleSm != null)
         output.AddCssClass("visible-sm-" + VisibleSm.Value.GetDescription());
     if (VisibleMd != null)
         output.AddCssClass("visible-md-" + VisibleMd.Value.GetDescription());
     if (VisibleLg != null)
         output.AddCssClass("visible-lg-" + VisibleLg.Value.GetDescription());
     if (VisiblePrint != null)
         output.AddCssClass("visible-print-" + VisiblePrint.Value.GetDescription());
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:26,代码来源:ResponsiveUtilitiesTagHelper.cs

示例14: BootstrapProcess

 protected override void BootstrapProcess(TagHelperContext context, TagHelperOutput output) {
     output.TagName = "div";
     output.AddCssClass("jumbotron");
     if (FullWidth) {
         output.PreContent.SetHtmlContent(@"<div class=""container"">");
         output.PostContent.SetHtmlContent(@"</div>");
     }
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:8,代码来源:JumbotronTagHelper.cs

示例15: BootstrapProcessAsync

 protected override async Task BootstrapProcessAsync(TagHelperContext context, TagHelperOutput output) {
     ChildDetectionMode = true;
     await output.GetChildContentAsync();
     ChildDetectionMode = false;
     output.TagName = RenderAsDiv ? "div" : "ul";
     output.AddCssClass("list-group");
     await output.GetChildContentAsync(false);
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:8,代码来源:ListGroupTagHelper.cs


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