开发者

Getting the link, not the anchor tag in ASP.NET MVC

开发者 https://www.devze.com 2023-03-18 02:21 出处:网络
I\'d like to write: <a href=\'@Html.LinkGenerator\'>Edit</a> instead of: @开发者_JS百科Html.ActionLink(\"Edit\", \"Edit\")

I'd like to write:

 <a href='@Html.LinkGenerator'>Edit</a>

instead of:

@开发者_JS百科Html.ActionLink("Edit", "Edit")

Where @Html.LinkGenerator is the name of an imaginary helper which only creates the link, not the whole anchor tag, for a given route and action.

What should I do?


You could use the Url.Action helper which is not imaginary but very real and does what you need:

<a href="@Url.Action("Edit", "Edit")">Edit</a>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号