Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75c3f9f
commit 8bd89a5
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
VisibilityTagHelperDemo/src/VisibilityTagHelperDemo/TagHelpers/VisibilityTagHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Razor.TagHelpers; | ||
|
||
namespace VisibilityTagHelperDemo.TagHelpers | ||
{ | ||
[HtmlTargetElement("div")] | ||
public class VisibilityTagHelper : TagHelper | ||
{ | ||
// default to true otherwise all existing target elements will not be shown, because bool's default to false | ||
public bool IsVisible { get; set; } = true; | ||
|
||
public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output) | ||
{ | ||
if (!IsVisible) | ||
output.SuppressOutput(); | ||
|
||
return base.ProcessAsync(context, output); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters