2016-07-27 17 views
5

我正在嘗試爲支持asp-hash屬性的a標籤創建自定義ASP.NET核標籤幫助程序。該屬性應該做的只是將提供的值附加到href屬性的末尾。然後使用哈希字符串支持創建自定義錨標籤助手

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

會產生:

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

我發現的源代碼AnchorTagHelper在本節asp.net github repo我無法找到一個方法來添加東西的末尾生成href

回答

6

asp-hash屬性存在,但不需要製作自定義錨標籤幫助程序。您正在尋找asp-fragment屬性:

<a asp-controller="Home" asp-action="Index" asp-fragment="mainDiv">some link</a> 
+0

愚蠢的我......沒注意到 – VSG24