Reputation: 1898
I have a problem navigating between different controllers views from HTML
Like for example i have two controllers (User and Transaction)
and in my HTML there is a main menu where it has all the main navigations.
so if i wanna navigate to the User list my view would be "User/List_Users"
and if i am inside the Transaction view
(......com/Transaction)
if i clicked on User List it will navigate to
(......com/Transaction/User/List_Users)
instead of going to
(......com/User/List_Users)
So i tried using The Html Action like like
<li>@Html.ActionLink("User List","User/List_Users")</li>
but didn't do any good :(
Upvotes: 0
Views: 3848
Reputation: 4083
I usually use the following
@Html.ActionLink("Link Text", "Action", "Controller", new { querystringparameter = querystringvalue }, null)
In your case it will be:
@Html.ActionLink("User List", "List_Users", "User", new { querystringparameter = querystringvalue }, null)
Upvotes: 2
Reputation: 2708
Use the overload which accepts controller name:
@Html.ActionLink("User List","List_Users", "User");
Upvotes: 2
Reputation: 34632
<li>@Html.ActionLink("Link Name", "Action")</li>
This is your basic ActionLink. An action is the specific method in the controller (which ultimately serves up a view).
If you need to link to a different controller (you need to link to a Transaction view from a User view, for example), you can do:
<li>@Html.ActionLink("Link Name", "Action", "Controller")</li>
Upvotes: 3