ShowIfTagHelper Class
A TagHelper that conditionally renders elements based on a boolean expression.
public sealed class ShowIfTagHelper : TagHelperExample
@model FormModel
@* Show content only if user is authenticated *@
<div show-if="@(User.Identity?.IsAuthenticated == true)">
Welcome back, @User.Identity?.Name!
</div>
@* Show error message conditionally *@
<div class="alert alert-danger" show-if="@Model.HasErrors">
Please correct the errors below.
</div>- Inheritance
TagHelperShowIfTagHelper
Constructors
| Name | Description |
|---|---|
| ShowIfTagHelper() |
ShowIfTagHelper()
public ShowIfTagHelper()No documentation is available.
Properties
| Name | Description |
|---|---|
| Value | Gets or sets the condition that determines whether the element should be rendered. |
Value
ShowIfTagHelper.csMethods
| Name | Description |
|---|---|
| Process(TagHelperContext, TagHelperOutput) | Processes the tag helper by either rendering or suppressing the element based on the condition. |
Process(TagHelperContext, TagHelperOutput)
ShowIfTagHelper.csProcesses the tag helper by either rendering or suppressing the element based on the condition.
public override void Process(TagHelperContext context, TagHelperOutput output)Parameters
contextTagHelperContext- Contains information about the current tag.
outputTagHelperOutput- A stateful HTML element used to generate an HTML tag.