本文整理汇总了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'>×</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);
}
示例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();
}
示例3: GetContent
private async Task<string> GetContent(TagHelperContext context)
{
if (Content == null)
return (await context.GetChildContentAsync()).GetContent();
return Content.Model?.ToString();
}
示例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);
}
}
}
}
}
示例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)));
}
示例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));
}
示例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)
);
}
示例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);
}
示例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());
}
示例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);
}
}
示例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;
}
示例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}
}
示例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();
}
}
示例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");
}
示例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);
}
}