Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC ActionLink how to specify text, actionname, controller and htmlattributes

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?

like image 442
AnonyMouse Avatar asked Jan 16 '12 20:01

AnonyMouse


2 Answers

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

@Html.ActionLink("Home", "Index", "Invoice", null, new { id = "homelink" })
like image 120
Per Kastman Avatar answered Nov 05 '22 11:11

Per Kastman


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

  • MSDN ActionLink Method (HtmlHelper, String, String, String, Object, Object)
like image 43
dknaack Avatar answered Nov 05 '22 09:11

dknaack