C
C#3w ago
conferza

Tag helper not working properly

i've been debugging this for a few hours now, i don't understand what's wrong. it's working in my other project... so the problem is a tag helper that doesn't show up on the page. this is what html it results in:
<div page-model="WebApp.ViewModels.PagingInfo" page-action="Index" page-classes-enabled="true" page-class="btn" page-class-normal="btn-outline-dark" page-class-selected="btn-primary" class="btn-group pull-right m-1"></div>
<div page-model="WebApp.ViewModels.PagingInfo" page-action="Index" page-classes-enabled="true" page-class="btn" page-class-normal="btn-outline-dark" page-class-selected="btn-primary" class="btn-group pull-right m-1"></div>
this is what it looks like in code (i checked the viewmodel that i'm passing here, it's not null, the data gets correctly populated):
<div page-model="@Model.PagingInfo" page-action="Index" page-classes-enabled="true"
page-class="btn" page-class-normal="btn-outline-dark"
page-class-selected="btn-primary" class="btn-group pull-right m-1"></div>
<div page-model="@Model.PagingInfo" page-action="Index" page-classes-enabled="true"
page-class="btn" page-class-normal="btn-outline-dark"
page-class-selected="btn-primary" class="btn-group pull-right m-1"></div>
PagingInfo contains a few properties related to pagination. the viewmodel contains it along with a collection of objects that need to be displayed on the page (which do get displayed properly) imports are in place, pagination using a query string in the search bar works properly, but no buttons are displayed below!!! ugh. this is what it's supposed to look like (example from my other project. don't mind the link, it uses conventional routing instead of query string that i used for simplicity):
<div class="btn-group pull-right m-1">
<a class="btn btn-primary" href="/products/page1">1</a>
<a class="btn btn-outline-dark" href="/products/page2">2</a>
</div>
<div class="btn-group pull-right m-1">
<a class="btn btn-primary" href="/products/page1">1</a>
<a class="btn btn-outline-dark" href="/products/page2">2</a>
</div>
i'll send the PageLinkTagHelper.cs in a message below
4 Replies
MODiX
MODiX3w ago
conferza
sharplab.io (click here)
namespace WebApp.TagHelpers;
[HtmlTargetElement("div", Attributes = "page-model")]
public class PageLinkTagHelper : TagHelper {
private readonly IUrlHelperFactory urlHelperFactory;
public PageLinkTagHelper(IUrlHelperFactory helperFacto... {
this.urlHelperFactory = helperFactory;
}
public bool PageClassesEnabled { get; set; }
public string PageClass { get; set; } = string.Empty;
public string PageClassNormal { get; set; } = string.E...
// 34 more lines. Follow the link to view.
namespace WebApp.TagHelpers;
[HtmlTargetElement("div", Attributes = "page-model")]
public class PageLinkTagHelper : TagHelper {
private readonly IUrlHelperFactory urlHelperFactory;
public PageLinkTagHelper(IUrlHelperFactory helperFacto... {
this.urlHelperFactory = helperFactory;
}
public bool PageClassesEnabled { get; set; }
public string PageClass { get; set; } = string.Empty;
public string PageClassNormal { get; set; } = string.E...
// 34 more lines. Follow the link to view.
React with ❌ to remove this embed.
conferza
conferzaOP3w ago
oh my fucking god... the problem turned out the be this: @addTagHelper *, WebApp.TagHelpers which should've been @addTagHelper *, WebApp how does that even make sense?! there's literally @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers right above it what a ridiculous issue well, i'm glad it's over now
Sehra
Sehra3w ago
the second parameter is an assembly name, not a namespace
conferza
conferzaOP3w ago
that makes sense NOW but i had no clue thanks

Did you find this page helpful?