3

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.

1 Answer 1

3

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>.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.