I have this method in my controller called "DirectorySearchController"
public ActionResult PersonDetails(FoundPerson person) //for some reason person is null here
{
DirectoryViewModel viewModel = new DirectoryViewModel();
viewModel.person = person;
return View(viewModel);
}
When I pass some parameters to it from the view using Html.Actionlink it returns a null value
<ul data-role="listview">
@if (ViewBag.Message == "NO RESULTS FOUND")
{
<li>@ViewBag.Message</li>
}
else
{
foreach (var employee in Model)
{
<li>
<div class="ui-grid-b">
<div class="ui-block-a" style="width:20%; vertical-align:middle"><img src="@employee.pictureURL" width="40px" height="40px"/></div>
<div class="ui-block-b" style="width:80%; vertical-align:middle">@Html.ActionLink(employee.name, "PersonDetails", "DirectorySearch", new { person = employee}, null)</div>
</div>
</li>
}
}
</ul>
But the funny thing is that when I pass the parameter without using the "new" keyword it passes the correct value. However, the problem is I need to pass multiple parameters so I need to use the "new" keyword.
<div class="ui-block-b" style="width:80%; vertical-align:middle">@Html.ActionLink(employee.name, "PersonDetails", "DirectorySearch", employee, null)</div>