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


C# TagHelperContext.GetChildContentAsync方法代码示例

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


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

示例1: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var childContent = await context.GetChildContentAsync();
            var content = childContent.GetContent();
            var template =
[email protected]"<div class='modal-dialog' role='document'>
    <div class='modal-content'>
      <div class='modal-header'>
        <button type = 'button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
        <h4 class='modal-title' id='{context.UniqueId}Label'>{Title}</h4>
      </div>
        {content}
    </div>
  </div>";
            output.TagName = "div";
            output.Attributes["role"] = "dialog";
            output.Attributes["id"] = Id;
            output.Attributes["aria-labelledby"] = $"{context.UniqueId}Label";
            output.Attributes["tabindex"] = "-1";
            var classNames = "modal fade";
            if (output.Attributes.ContainsName("class"))
            {
                classNames = string.Format("{0} {1}", output.Attributes["class"].Value, classNames);
            }
            output.Attributes["class"] = classNames;

            output.Content.SetContent(template);
        }
开发者ID:arashkeivan,项目名称:TagHelperSamples,代码行数:28,代码来源:ModalTagHelper.cs

示例2: ProcessAsync

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

示例3: GetContent

        private async Task<string> GetContent(TagHelperContext context)
        {
            if (Content == null)
                return (await context.GetChildContentAsync()).GetContent();

            return Content.Model?.ToString();
        }
开发者ID:freemsly,项目名称:TagHelperSamples,代码行数:7,代码来源:MarkdownTagHelper.cs

示例4: ProcessAsync

        /// <inheritdoc />
        /// <remarks>Does nothing if <see cref="For"/> is <c>null</c>.</remarks>
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (For != null)
            {
                var tagBuilder = Generator.GenerateValidationMessage(ViewContext,
                                                                     For.Name,
                                                                     message: null,
                                                                     tag: null,
                                                                     htmlAttributes: null);

                if (tagBuilder != null)
                {
                    output.MergeAttributes(tagBuilder);

                    // We check for whitespace to detect scenarios such as:
                    // <span validation-for="Name">
                    // </span>
                    if (!output.IsContentModified)
                    {
                        var childContent = await context.GetChildContentAsync();

                        if (childContent.IsWhiteSpace)
                        {
                            // Provide default label text since there was nothing useful in the Razor source.
                            output.Content.SetContent(tagBuilder.InnerHtml);
                        }
                        else
                        {
                            output.Content.SetContent(childContent);
                        }
                    }
                }
            }
        }
开发者ID:AndersBillLinden,项目名称:Mvc,代码行数:36,代码来源:ValidationMessageTagHelper.cs

示例5: ProcessAsync

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

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

示例6: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var childContent = await context.GetChildContentAsync();
            var parsedContent = MarkdownParser.Transform(childContent.GetContent());

            output.Content.SetContent(new HtmlString(parsedContent));
        }
开发者ID:NTaylorMullen,项目名称:OrchardConf_10_5_2015,代码行数:7,代码来源:MarkdownTagHelper.cs

示例7: ProcessAsync

 public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     output.TagName = null;
     output.TagMode = TagMode.SelfClosing;
     output.Content.SetContent(
         NugetGenerator.GenerateNugetPanel(Package, (await context.GetChildContentAsync()).ToString(), Repository)
     );
 }
开发者ID:freemsly,项目名称:Acme.Helpers,代码行数:8,代码来源:NugetPanelTagHelper.cs

示例8: ProcessAsync

 public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     output.TagName = "a";    // Replaces <email> with <a> tag
     var content = await context.GetChildContentAsync();
     var target = content.GetContent() + "@" + EmailDomain;
     output.Attributes["href"] = "mailto:" + target;
     output.Content.SetContent(target);
 }
开发者ID:dvincent,项目名称:Docs,代码行数:8,代码来源:EmailTagHelper.cs

示例9: ProcessAsync

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

            output.TagName = null;
            output.Content.SetContent(HtmlHelper.DisplayName(AspFor.Metadata.PropertyName).SplitCamelCase());
            output.Content.Append(await context.GetChildContentAsync());
        }
开发者ID:Anderman,项目名称:helpers.mvc,代码行数:8,代码来源:DisplayNameTagHelper.cs

示例10: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            for (var i = 0; i < this.Count; i++)
            {
                var html = await context.GetChildContentAsync(false);
                output.Content.Append(html);
            }

        }
开发者ID:LukaszSzulc,项目名称:TGD.NET,代码行数:9,代码来源:RepeatTagHelper.cs

示例11: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            for (int i = 0; i < Count; i++)
            {
                output.Content.Append(await context.GetChildContentAsync(false));
            }

            output.TagName = null;
        }
开发者ID:Gutek,项目名称:20151030-dot-net-conf-pl,代码行数:9,代码来源:RepeatTagHelper.cs

示例12: ProcessAsync

 public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     var childContent = await context.GetChildContentAsync();
     // Find Urls in the content and replace them with their anchor tag equivalent.
     output.Content.SetContent(Regex.Replace(
          childContent.GetContent(),
          @"\b(?:https?://)(\S+)\b",
           "<a target=\"_blank\" href=\"$0\">$0</a>"));  // http link version}
 }
开发者ID:dvincent,项目名称:Docs,代码行数:9,代码来源:z1AutoLinker.cs

示例13: ProcessAsync

 public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     if (context.AllAttributes["managed"].Value.ToString() == "true")
     {
         var content = await context.GetChildContentAsync();
         _manager.Scripts.Add(content);
         output.SuppressOutput();
     }
 }
开发者ID:glennc,项目名称:GHUtils,代码行数:9,代码来源:ScriptManager.cs

示例14: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var childContent = await context.GetChildContentAsync();
            var parsedContent = MarkdownParser.Transform(childContent.GetContent());

            output.Content.SetContentEncoded(parsedContent);

            output.Attributes.RemoveAll("markdown");
        }
开发者ID:NTaylorMullen,项目名称:MVPSummit_2015,代码行数:9,代码来源:MarkdownTagHelper.cs

示例15: ProcessAsync

        public async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) {
            if (Count <= 0) {
                return;
            }

            for (int i = 0; i < Count; i++) {
                var content = await context.GetChildContentAsync();
                output.Content.Append(content);
            }
        }
开发者ID:tkopacz,项目名称:aspnet5-tkdemo-beta7,代码行数:10,代码来源:RepeatTagHelper.cs


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