0

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 :(

3 Answers 3

3
<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>
Sign up to request clarification or add additional context in comments.

1 Comment

@BOSS - If this answer helped you, please go ahead and accept (checkmark over to the left). Thanks!
2

Use the overload which accepts controller name:

@Html.ActionLink("User List","List_Users", "User");

Comments

2

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.