I checked all the solutions but still doesnt work.I got a partial view page in layout page and When ı run only partial page it works but when ı run another page with layout it doesnt work.
I hope you can help me
Here is my Model :
public CheckListType CheckListType { get; set; }
public IEnumerable<SelectListItem> CheckListTypeList1 { get; set; }
And my Controller :
public ActionResult ListCheckListType()
{
ControlListTypeModel listTypeModel = new ControlListTypeModel();
List<SelectListItem> CheckListTypeList = new List<SelectListItem();
foreach (CheckListType item in checklisttypeRepository.List().ProcessResult)
{
CheckListTypeList.Add(new SelectListItem { Value = item.CheckListTypeId.ToString(), Text = item.CheckListType1 });
}
listTypeModel.CheckListTypeList1 = CheckListTypeList;
return PartialView("~/Areas/User/Views/CheckList/ListCheckListType.cshtml", listTypeModel);
}
View :
@using TodoListApp.Areas.User.Models.ViewModel
@model ControlListTypeModel
<form action="/CheckList/ListCheckListType" method="get">
<div>
CheckListType :
</div>
<div>
@Html.DropDownListFor(modelitem=>modelitem.CheckListType.CheckListTypeId,Model.CheckListTypeList1)
<button type="button" class="butt button bg-info" style="height:40px; width:98px;">Choose CheckListType</button>
</div>
Layout :
<div class="container body-content">
@Html.Action("ListCheckListType");
@RenderBody(){
}
<hr />
<footer>
<p> @DateTime.Now.Year </p>
</footer>
</div>
HttpException: A public action method 'ListCheckListType' was not found on controller
The problem occurs because it searches ListCheckListType
action in wrong controller while rendered in partial view. Specifying controller name as well should fix the exception
@Html.Action("ListCheckListType", "Home"); //if action is in HomeController