Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys, I have a little problem which to seasoned MVC pros might seem silly but I'm pretty new to MVC after programming in Web Forms for the last couple of years. Ok my problem, I have a strongly typed view which displays a list of my Models which is displayed in a grid. I want to be ably to redirect to my "Edit" action of my controller whenever the user clicks one of the buttons in the grid. I have tried doing in both Jquery and in the view but I'm having no luck.

View
HTML
<button type="button" id="Edit" name='Edit' onclick="window.location.href('@Url.Action("Edit","Account")')"></button>


Controller
C#
public ActionResult Edit()
       {
           return View();
       }


So the below code is not working. I just need to know the correct way to redirect to the Edit action. Thanks in advance for your help.
Posted

1 solution

You should change your code from the view like this;
HTML
<button type="button" id="Edit" name='Edit' onclick="self.location='@Url.Action("Edit","Account")'"></button>
 
Share this answer
 
Comments
frostcox 5-Jul-14 15:06pm    
excellent thank you!
Raul Iloc 6-Jul-14 2:21am    
Welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900