I am trying to pass a model to my partial class in asp.net however it keeps giving me the following error:
I tried calling the partial class the following ways:
<section id="categoryPartial">
@*1*@ @Html.Partial("_CategoryPartial", new EindopdrServer.Models.Category())
@*2*@ @Html.Partial("_CategoryPartial", new EindopdrServer.Models.Category{ Name => Model.Name })
@*3*@ @Html.RenderPartial("_CategoryPartial", new EindopdrServer.Models.Category { Name => Model.Name })
</section>
My partial class:
@model IEnumerable<EindopdrServer.Models.Category>
<table>
<tr>
@if(Model != null){
@foreach (var item in Model) {
<td class="categoryPartial">
<a href="Products/SearchIndex?productGenre=@item.Name"><b>@Html.DisplayFor(modelItem => item.Name)</b></a>
</td>
}
}
</tr>
</table>
Any solutions?
After removing the @ and if statement: