简体   繁体   中英

How to turn HTML link into ASP.NET MVC action link with attributes

I try to convert this HTML link

Projects

into MVC code, but I don't know how to add the href and the aria-expanded attributes

@Html.ActionLink("Project", "ProjectDetails", "Project", new { @class = "has-arrow" })

Can anyone help please?

You can do the following to your ActionLink :

@Html.ActionLink("Projects", "ProjectDetails", "Project", new {href="javascript:void(0)", @class = "has-arrow", @aria-expanded="false"})

This will convert to your a tag in the question

its works like that

                @Html.ActionLink("Projects", "ProjectDetails", "Project", new { href = "javascript:void(0)", @class = "has-arrow", @ariaexpanded = "false" })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM