Anshu Kumar

Anshu Kumar

  • NA
  • 1.2k
  • 22.3k

Calling Action from View

Jul 31 2014 7:02 AM
How to call an action method from view hyperlink or button. Action method have few input parameters.
I tried to call the view from hyperlink to fill the Model and populate the view respectively. 
 
@Html.ActionLink("GetEmployee","GetEmpView","Employee",new {@empid= 1001, @fstname="Anshu",@lstname="Singh"}, null)
 
public ActionResult GetEmpView(int empid, string fstname, string lstname)
{
EmployeeModels emp1 = new EmployeeModels();
emp1.EmployeeID = empid;
emp1.FirstName = fstname;
emp1.LastName = lstname;
return View(emp1);
}
 
 

Answers (1)