0

I would like to be able to do a strongly typed view/user control, where the type is a list of generic types. Like so:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<PagedList<T>>" %>

but is not working, as is actually searching for that type. The reason I need it is because the user control (which is just displaying pagination) will be used with lists of objects of different type, and I don't want to recreate it for each of them.

Any ideas?

1 Answer 1

2

You should have a base class or an interface that the view can use.

class PagedList<T> : PagedList {
  // magic
}

Then in your view

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<PagedList>" %>
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.