MVC ActionLink how to specify text, actionname, controller and htmlattributes
Asked Answered
R

2

5

I have been trying to do an actionlink like:

<li>@Html.ActionLink("Home", "Index", "Invoice", new { id = "homelink" })</li>

So what I have is linkText, an actionname, a controller name and an id for the link.

However there is no signature that matches this. The closest one has routevalues between the controller name and the htmlattributes. I don't have any routevalues I need to put in there though.

Can someone please tell me how to best get around this?

Romelda answered 16/1, 2012 at 20:39 Comment(0)
B
6

Set route values to null and your're good to go!

@Html.ActionLink("Home", "Index", "Invoice", null, new { id = "homelink" })
Butterbur answered 16/1, 2012 at 20:41 Comment(0)
B
3

Description

Assuming i understand what you are asking for, there is an overload for that

Sample

@Html.ActionLink("LinkText", "ActionName", "ControllerName", 
                  null, new { id="homelink" })

More Information

Beguine answered 16/1, 2012 at 20:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.