更新时间:2023-02-24 22:46:19
您应该从这样的视图中更改您的代码;< 按钮 type = button id = 编辑 名称 =' 编辑' onclick = self.location ='@ Url.Action( 编辑,帐户)' > < / button >
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
<button type="button" id="Edit" name='Edit' onclick="window.location.href('@Url.Action("Edit","Account")')"></button>
Controller
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.
You should change your code from the view like this;<button type="button" id="Edit" name='Edit' onclick="self.location='@Url.Action("Edit","Account")'"></button>