I have a View of type "List<SimpleUser>"
and I want to pass to my controller the object that is in my foreach, however this is arriving null being done as follows:
View:
@{
ViewBag.Title = "Dashboard";
}
<!-- search form -->
<form action="#" method="get" class="sidebar-form">
<div class="input-group">
<input type="text" name="q" class="form-control" placeholder="Buscar entre seus clientes/pacientes..." />
<span class="input-group-btn">
<button type='submit' name='seach' id='search-btn' class="btn btn-flat"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
@if (Model.Count() > 0)
{
foreach (var sUser in Model)
{
<div>
@Html.ActionLink(@sUser.Name, "ClientDetails", "ProfessionalUserHasClient", new { simpleUser = sUser })
</div>
}
}
else
{
<label>Você não tem clientes/pacientes vinculados.</label>
}
Controller:
public ActionResult ClientDetails(SimpleUser simpleUser)
{
SimpleUser sUser = ViewBag.SimpleUser as SimpleUser;
return View();
}
If you change to @Html.Action()
, it passes nicely however it is loaded inside View
, a part of the entire layout, which obviously should not be loaded, follows a print of what it would look like: