Reputation: 9572
I'm wanting to have a strongly typed user control that accepts the class PaginatedList<T>
What will my signature for this user control look like and how do I render it?
At the moment I have this as my signature for the user control:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Project.Models.PaginatedList<Project.Models.Product>>" %>
Obviously this doesn't work when I pass a PaginatedList that holds something other than a product. Like here, when I want to send it a PaginatedList of news items:
<% Html.RenderPartial("Pagination", Model.NewsItems); %>
Any help would be much appreciated.
Upvotes: 3
Views: 580
Reputation: 144162
You could try making your control less strongly-typed and use something like ViewUserControl<IEnumerable>
. Or, if you need some of the specific functionality of your PaginatedList, try creating a weakly-typed interface for your PaginatedList class and do ViewUserControl<IPaginatedList>
.
Upvotes: 3