To disable a tag helper at the element level, you can use the ! character before the opening tag. For example, the following code will disable the
label tag helper:
HTML
<!label for="username">Username</label>
The ! character tells the tag helper to not render any HTML. This can be useful if you want to conditionally disable a tag helper, based on some condition. For example, you could use the
! character to disable a tag helper if a user is not logged in.
Here is an example of how to conditionally disable the label tag helper:
In this example, the label tag helper will only be rendered if the user is logged in. If the user is not logged in, the
label tag helper will not be rendered.
You can also disable a tag helper at the view level by using the @removeTagHelper directive. For example, the following code will remove the
label tag helper from all views in the current folder:
HTML
@removeTagHelper TagHelperName="label"
The @removeTagHelper directive can be used to disable any tag helper, regardless of the element level. This can be useful if you want to disable a tag helper globally, for all views in your application.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
To disable a tag helper at the element level, you can use the
!character before the opening tag. For example, the following code will disable thelabeltag helper:HTML
The
!character tells the tag helper to not render any HTML. This can be useful if you want to conditionally disable a tag helper, based on some condition. For example, you could use the!character to disable a tag helper if a user is not logged in.Here is an example of how to conditionally disable the
labeltag helper:HTML
In this example, the
labeltag helper will only be rendered if the user is logged in. If the user is not logged in, thelabeltag helper will not be rendered.You can also disable a tag helper at the view level by using the
@removeTagHelperdirective. For example, the following code will remove thelabeltag helper from all views in the current folder:HTML
The
@removeTagHelperdirective can be used to disable any tag helper, regardless of the element level. This can be useful if you want to disable a tag helper globally, for all views in your application.