Creating a custom anchor tag helper with hash string support
Asked Answered
E

1

9

I'm trying to create a custom ASP.NET Core tag helper for a tag that supports asp-hash attribute. What that attribute is supposed to do is just append the provided value to the end of the href attribute.

<a asp-controller="Home" asp-action="Index" asp-hash="mainDiv">some link</a>

would then generate:

<a href="http://localhost/home/index#mainDiv">some link</a>

I found the source code for AnchorTagHelper in this section in asp.net github repo but I can't find a way to append stuff to the end of generated href.

Einberger answered 27/7, 2016 at 18:8 Comment(0)
C
15

No asp-hash attribute exists, but there is no need to make a custom anchor tag helper. You are looking for asp-fragment attribute:

<a asp-controller="Home" asp-action="Index" asp-fragment="mainDiv">some link</a>
Chandos answered 7/8, 2016 at 16:33 Comment(1)
Stupid me... didn't notice thatEinberger

© 2022 - 2024 — McMap. All rights reserved.