aa003
aa003

Reputation: 131

How to call Html.ActionLink in Partial View?

My structure of Controllers and Views is as follow

Controller
         |_Disorders
         |         |_Anxiety
         |                  |_AnxietyController
         | HomeController



 Views
        |_Anxiety
        |        |_Anxiety.aspx
        |_Home
             |_Index.aspx  

I am trying to call this from partial view which is located as follow:

Views
     |_Shared
     |        |_Header.ascx // header is included in Site.Master
     |
     |Site.Master 

I am putting this code in Header.ascx

<li><% Html.ActionLink("Home", "Index", "Home"); %></li>
<li><% Html.ActionLink("Anxiety", "Anxiety", "Anxiety"); %></li>

I have followed this Html.ActionLink(linktext, Actionname, controllername) but unable to fix it.

Its in MVC3

Upvotes: 0

Views: 629

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239290

The controller param isn't a path. It's just the name of the controller, i.e. _Anxiety based on your class of _AnxietyController. (The Controller bit is left off intentionally. That is how the helper expects it. It knows all your controllers end in Controller.)

Upvotes: 1

Related Questions