JavaScript
<script type="text/javascript">
$(function () {
$("[ID*=btnAdd]").click(function () {
//Here I am passing routing value i.e student
var url = '@Url.Action("GetPV", "Home", new { students=Model.Students })';
$('#grid1').load(url);
});
});
HTML
<div id="grid1"></div>
<input type="button" id="btn" Value="Submit"/>
MVC Action
//Here iam getting students parameter as null
public ActionResult GetPV(List<Student> students)
{
students.Add(new Student());
StudentModel objstudentmodel = new StudentModel();
objstudentmodel.StudentList = students;
return PartialView("_DemoPV", objstudentmodel);
}
Model
public class StudentModel
{
public List<Student> StudentList { get; set; }
}
public class Student
{
public int Id { get; set; }
public string Name { get; set; }
public string Mobile { get; set; }
public string Email { get; set; }
public string Nationality { get; set; }
public List<HttpPostedFile> files { get; set; }
}
I want to load the partial view through jquery on button click event.
In this scenario, I want to pass student list as parameter to action method.
Here I am not able to pass the routing values from jquery URL Action to the MVC Action method.
Please assist me to resolve the issue. Thanks.