Hi Guys,
I have a main page which uses a ViewModel I have created:
public class HomeViewModel
{
public List<Category> Categories { get; set; }
public List<Image> Images { get; set; }
public HomeViewModel(List<Image> images, List<Category> categories)
{
Images = images;
Categories = categories;
}
}
On my main page I am outputing the Categories but then passing the Images through to a PartialView.
<div id="gallery">
<% Html.RenderPartial("gallery", Model.Images); %>
</div>
When I run my work I am getting this error: error CS0308: The non-generic type 'System.Collections.IEnumerable' cannot be used with type arguments
This is my partial view:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<Gallery.Models.Image>>" %>
<%@ Import Namespace="Gallery.Helpers" %>
<ul>
<% foreach (var item in Model)
{ %>
<li>
<%= Html.ImageLink(item.imageID.ToString(), Url.Content("~/Uploads/" + item.imageLocation).ToString(), item.imageDescription, Url.Content("~/Uploads/" + item.imageThumb).ToString(), item.imageDescription, null)%>
</li>
<% } %>
</ul>
I was using .NET 4 and this worked fine but I understand they have altered Generics since 3.5 which made it possible. However my web server company hasn't upgraded their servers meaning I have to deploy using 3.5. I have got the Partial to work if I cast the Partial as the same object as the Main page but then I am passing through more ViewData than I need to. The reason I am using Partials is to take advantage of AJAX in the .NET framework. E.g. the Categories are AJAX links goto a method that method returns an updated Partial with the category images, I should only need to pass Images into the Parial.
Any help on solving this would be appreciated.
Thanks,
Jon