Skip to content

Instantly share code, notes, and snippets.

Created March 14, 2023 12:05
What would you like to do?
If block TagHelper
[HtmlTargetElement("*", Attributes = "[asp-if]")]
public class IfTagHelper : TagHelper
/// <summary>
/// Shows the element when this condition is true
/// </summary>
public bool IsTrue { get; set; } = true;
public override void Process(TagHelperContext context, TagHelperOutput output)
if (!IsTrue)
output.TagName = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment