Tag helpers render properly on ALL my razor
pages but not in my ViewComponents
For instance:
<label asp-for="MiddleName" class="control-label"></label>
should render as:
<label class="control-label" for="Contact_MiddleName">Middle Name</label>
but instead simply is included in the page as is.
I have searched the web high and low for hours but can't find any solution. Any pointers on what to try?
I guess asking the question here gave me an idea.
In my _ViewImports.cshtml file I have
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
which enables tag helpers on all my razor
pages
. On a whim I added it to the top of my ViewComponent.cshtml
and now it works.
I still don't know why I have to add it to each view component file. If someone can give me the answer for that I'll mark your answer as the correct one.
You have to add in _ViewImports.cshtm tag helper with the name of your project.
@addTagHelper *, ProjectName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With