jetbrains logo Getting Started with HTMX - Complete

12. ASP.NET Core Tag Helpers

During your journey through the different samples, you've likely noticed the use of Url.Page to generate links to each Razor page. While the approach works, it can be noisy and tedious. Instead, you can use the tag helpers found in Htmx.TagHelpers to generate links to any ASP.NET Core endpoint. HTMX.NET models the tag helpers after the asp- tag helpers found in ASP.NET Core so that you can create links to endpoints, MVC actions, and Razor Pages. Let's look at an example.

hx-get
hx-page="12_TagHelpers"
hx-target="#target"

In this case, you need to specify the HTTP method version of the hx attribute, and then you can use hx-page to point to our Razor Page. Using these tag helpers can help you keep our Razor views clean and concise.


Change Me!