ToString1
asked on
MVC HTML.Actionlink to route to different controller action
What is the best approach to route the following to a controller action from anywhere with an MVC app? The following code is everywhere in the app and I need to make it a link so that it routes back to a user details page. I have two areas in the app SuperAdmin and TeamAdmin and I want to redirect back to the SuperAdmin edit user page if in SuperAdmin area and route back to the TeamAdmin area if in TeamAdmin. I guess I may need to replicate a bit of edit user functionality as they both do different things.
So this needs amending so if clicked on it goes to the users controller "details" action passing the userID
<%= Html.Encode(Model.Originat ingUser.Fi rstName + ", " + Model.OriginatingUser.Surn ame) %>
So this needs amending so if clicked on it goes to the users controller "details" action passing the userID
<%= Html.Encode(Model.Originat
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm still getting to grips with MVC.
Could you provide a code example please modifying this?
Html.ActionLink( Html.Encode(Model.User.Use rname), "RedirectToUser", "UserController", new {id=Model.User.Id } )%>
Could you provide a code example please modifying this?
Html.ActionLink( Html.Encode(Model.User.Use
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
IT actually redirects to
applicationName/RedirectTo User
It thinks that "RedirectToUser" is a view - where in my code ive got a redirectToAction called "RedirectToUser"
Wherever I am in the application I want to route it to the Users conroller "edit" method
applicationName/RedirectTo
It thinks that "RedirectToUser" is a view - where in my code ive got a redirectToAction called "RedirectToUser"
Wherever I am in the application I want to route it to the Users conroller "edit" method
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So I guess what I am saying is that I want to implement the following
I have a username "Doe, Jon" Clicking on that from wherever it is displayed in any view I want to navigate to
myApp/Users/Edit/1
As I already know the userID
I have a username "Doe, Jon" Clicking on that from wherever it is displayed in any view I want to navigate to
myApp/Users/Edit/1
As I already know the userID
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks nmarun
Brilliant
Sorry I was causing confusion
Brilliant
Sorry I was causing confusion
ASKER
I need something this
Html.ActionLink( Html.Encode(Model.User.Use
So if it is made into a user control it will redirect to the user details page