Following code show how we can call controller action and pass the required data to the controller on click of Link/ActionLink. here name and order of parameter must be same in sending and receiving place.
/*Razor Code*/
/*Razor Code*/
@Html.ActionLink(item.PersonName, "GetInfo", new { Name = item.PersonName, age= item.PersonAge})
/*Controller Code*/
public ActionResult GetInfo(string Name, string age)
{
//then you can write your logic here
int age=convert.ToInt32(age);
return View();
}
{
//then you can write your logic here
int age=convert.ToInt32(age);
return View();
}
/* Names and order of arguments passed in ActionLink and received in Controller action must be same*/
No comments:
Post a Comment