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


C# TagHelpers.TagHelperOutput类代码示例

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


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

示例1: Process

 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     output.TagName = "p";
     output.Attributes["class"] = "example";
     output.PostContent.SetContent("Hello from the tag helper! ");
     output.PostContent.Append("Title sent in was: " + Title + " and Body: " + Body);
 }
开发者ID:LadyLizzy,项目名称:mvc6-example,代码行数:7,代码来源:ExampleTagHelper.cs

示例2: Process

 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     if (HideIf)
     {
         output.SuppressOutput();
     }
 }
开发者ID:RR-Studio,项目名称:RealEstateCrm,代码行数:7,代码来源:HideTagHelper.cs

示例3: Process

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            StringBuilder sb = new StringBuilder();

            string menuUrl = _UrlHelper.Action(ActionName, ControllerName, new { Area = AreaName });

            if (string.IsNullOrEmpty(menuUrl))
                throw new InvalidOperationException(string.Format("Can not find URL for {0}.{1}", ControllerName, ActionName));

            output.TagName = "li";

            var a = new TagBuilder("a");
            a.MergeAttribute("href", $"{menuUrl}");
            a.MergeAttribute("title", MenuText);
            a.InnerHtml.Append(MenuText);

            var routeData = ViewContext.RouteData.Values;
            var currentController = routeData["controller"];
            var currentAction = routeData["action"];
            var currentArea = routeData.ContainsKey("area") ? routeData["area"] : string.Empty;

            if (string.Equals(ActionName, currentAction as string, StringComparison.OrdinalIgnoreCase)
                && string.Equals(ControllerName, currentController as string, StringComparison.OrdinalIgnoreCase)
                && string.Equals(AreaName, currentArea as string, StringComparison.OrdinalIgnoreCase))
            {
                output.Attributes.Add("class", "active");
            }

            output.Content.SetContent(a);
        }
开发者ID:AugustinasNomicas,项目名称:BookingSystem,代码行数:30,代码来源:MenuLinkTagHelper.cs

示例4: Process

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {

            output.TagName = "select";

            if (Disabled)
            {
                output.Attributes["disabled"] = "disabled";
            }


            var items = new StringBuilder();
            var cityList = DbContext.Cities.OrderBy(x => x.Name).ToList();

            items.Append("<option value=\"\">Все города</option>");
            foreach (var city in cityList)
            {
                if (city.Id == CityId)
                {
                    items.Append($"<option value=\"{city.Id}\" selected=\"true\">{city.Name}</option>");
                }
                else
                {
                    items.Append($"<option value=\"{city.Id}\">{city.Name}</option>");
                }
            }
        
            output.Content.SetHtmlContent(items.ToString());
            output.Attributes.Add("class", "ui fluid dropdown");
        }
开发者ID:RR-Studio,项目名称:RealEstateCrm,代码行数:30,代码来源:CitySelectList.cs

示例5: Process

 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     output.PostContent
         .AppendHtml("<footer>")
         .Append((string)ViewContext.ViewData["footer"])
         .AppendHtml("</footer>");
 }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:7,代码来源:FooterTagHelper.cs

示例6: Process

        /// <inheritdoc />
        /// <remarks>Does nothing if <see cref="ValidationSummary"/> is <see cref="ValidationSummary.None"/>.</remarks>
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            if (ValidationSummary == ValidationSummary.None)
            {
                return;
            }

            var tagBuilder = Generator.GenerateValidationSummary(
                ViewContext,
                excludePropertyErrors: ValidationSummary == ValidationSummary.ModelOnly,
                message: null,
                headerTag: null,
                htmlAttributes: null);
            if (tagBuilder != null)
            {
                output.MergeAttributes(tagBuilder);
                output.PostContent.Append(tagBuilder.InnerHtml);
            }
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:31,代码来源:ValidationSummaryTagHelper.cs

示例7: 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

示例8: Process

        public override async void Process(TagHelperContext context, TagHelperOutput output)
        {
            var originalContent = await output.GetChildContentAsync();

            output.AppendClass("form-group");

            TagBuilder labelBuilder = null;
            if (!originalContent.GetContent().Contains("<label"))
            {
                labelBuilder = FormGroupLabel.Get(Horizontal, LabelText);
            }

            var contentDiv = new TagBuilder("div");

            if (Horizontal)
            {
                contentDiv.AddCssClass("col-sm-8");
            }

            contentDiv.InnerHtml.AppendHtml(originalContent.GetContent());
            
            output.TagName = "div";
            output.Content.Clear();
            if (labelBuilder != null)
            {
                output.Content.Append(labelBuilder);
            }
            output.Content.Append(contentDiv);

            base.Process(context, output);
        }
开发者ID:neutmute,项目名称:steelcap,代码行数:31,代码来源:FormGroupTagHelper.cs

示例9: 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

示例10: Process

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            TagBuilder table = new TagBuilder("table");
            table.GenerateId(context.UniqueId, "id");
            var attributes = context.AllAttributes.Where(a => a.Name != ItemsAttributeName).ToDictionary(a => a.Name);
            table.MergeAttributes(attributes);

            var tr = new TagBuilder("tr");
            var heading = Items.First();
            PropertyInfo[] properties = heading.GetType().GetProperties();
            foreach (var prop in properties)
            {
                var th = new TagBuilder("th");
                th.InnerHtml.Append(prop.Name);
              
                tr.InnerHtml.Append(th);
            }
            table.InnerHtml.Append(tr);
          
            foreach (var item in Items)
            {

                tr = new TagBuilder("tr");
                foreach (var prop in properties)
                {
                    var td = new TagBuilder("td");
                    td.InnerHtml.Append(prop.GetValue(item).ToString());
                    tr.InnerHtml.Append(td);
                }
                table.InnerHtml.Append(tr);
            }
            
            output.Content.Append(table.InnerHtml);
        }
开发者ID:CNinnovation,项目名称:TechConference2016,代码行数:34,代码来源:TableTagHelper.cs

示例11: WrapInDivForHorizontalForm

 public void WrapInDivForHorizontalForm(TagHelperOutput output, bool hasLabel) {
     if (Horizontal) {
         var builder = new TagBuilder("div") {TagRenderMode = TagRenderMode.StartTag};
         if (LabelWidthXs != 0) {
             builder.AddCssClass("col-xs-" + (12 - LabelWidthXs));
             if (!hasLabel)
                 builder.AddCssClass("col-xs-offset-" + LabelWidthXs);
         }
         if (LabelWidthSm != 0) {
             builder.AddCssClass("col-sm-" + (12 - LabelWidthSm));
             if (!hasLabel)
                 builder.AddCssClass("col-sm-offset-" + LabelWidthSm);
         }
         if (LabelWidthMd != 0) {
             builder.AddCssClass("col-md-" + (12 - LabelWidthMd));
             if (!hasLabel)
                 builder.AddCssClass("col-md-offset-" + LabelWidthMd);
         }
         if (LabelWidthLg != 0) {
             builder.AddCssClass("col-lg-" + (12 - LabelWidthLg));
             if (!hasLabel)
                 builder.AddCssClass("col-lg-offset-" + LabelWidthLg);
         }
         output.PreElement.Prepend(builder);
         output.PostElement.AppendHtml("</div>");
     }
 }
开发者ID:Pietervdw,项目名称:BootstrapTagHelpers,代码行数:27,代码来源:FormTagHelper.cs

示例12: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            (HtmlHelper as ICanHasViewContext)?.Contextualize(ViewContext);

            var content = await output.GetChildContentAsync();
            output.Content.SetContent(HtmlHelper.Hidden(Name, content.GetContent(HtmlEncoder)));
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:7,代码来源:HiddenTagHelper.cs

示例13: Process

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "select";
            output.TagMode = TagMode.StartTagAndEndTag;

            output.AppendClass("form-control");

            var optionsList = new List<TagBuilder>();

            if (Items == null)
            {
                Items = new List<SelectListItem>();
            }

            foreach (var item in Items)
            {
                var option = new TagBuilder("option");
                option.Attributes.Add("value", item.Value);
                option.InnerHtml.Append(item.Text);

                optionsList.Add(option);
            }

            optionsList.ForEach(o =>
            {
                output.Content.Append(o);
            });

            base.Process(context, output);
        }
开发者ID:neutmute,项目名称:steelcap,代码行数:30,代码来源:DropdownTagHelper.cs

示例14: Process

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            //if no scripts were added, suppress the contents
            if (!_httpContextAccessor.HttpContext.Items.ContainsKey(InlineScriptConcatenatorTagHelper.ViewDataKey))
            {
                output.SuppressOutput();
                return;
            }

            //Otherwise get all the scripts for the page
            var scripts =
                _httpContextAccessor.HttpContext.Items[InlineScriptConcatenatorTagHelper.ViewDataKey] as
                    IDictionary<string, NamedScriptInfo>;
            if (null == scripts)
            {
                output.SuppressOutput();
                return;
            }

            //Concatenate all of them and set them as the contents of this tag
            var allScripts = string.Join("\r\n", OrderedScripts(scripts.Values).Select(os => os.Script));
            output.TagMode = TagMode.StartTagAndEndTag;
            //HACK:Need to figure out how to get rid of the script tags for the placeholder element
            allScripts = $"</script><!--Rendered Scripts Output START-->\r\n{allScripts}\r\n</script><!--Rendered Scripts Output END--><script>";//HACK:ugly
            var unminifiedContent = output.Content.SetHtmlContent(allScripts);
            Debug.WriteLine(unminifiedContent.GetContent());
            //TODO:Impliment dynamic minification (Assuming that some scenarios will be sped up, and others slowed down.  Leave choice to user)
        }
开发者ID:SvdSinner,项目名称:ScriptManagerPlus,代码行数:28,代码来源:InlineScriptTagHelper.cs

示例15: ProcessAsync

 public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     var childContent = await output.GetChildContentAsync();
     var modalContext = (ModalContext)context.Items[typeof(ModalTagHelper)];
     modalContext.Body = childContent;
     output.SuppressOutput();
 }
开发者ID:candoumbe,项目名称:TagHelperSamples,代码行数:7,代码来源:ModalBodyTagHelper.cs


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