asp.net mvc 2 - how to implement a partial view with generic type inference -


i working through this sample , came across problem. implement pagination, sample extends list , adds pagination it. list used model.

in view want add pagination control. in sample add page want make user control because plan implement pagination in multiple pages. off course has typed view since can't use wildcards in c# can not implement this:

<%@ control language="c#" inherits="system.web.mvc.viewusercontrol<paginatedlist<?>>" %> 

since plan use members declared in paginatedlist , not in list don't need type.

in c# method solve problem type inference how don in partial view?

define interface containing pagination properties want use in partial view. have paginatedlist<t> class implement interface. have partial view typed interface.

public interface ipaginated {     int pageindex  { get; }     int pagesize   { get; }     int totalcount { get; }     int totalpages { get; } }  public class paginatedlist<t> : list<t>, ipaginated {    ... should not need change ... }  <%@ control language="c#" inherits="system.web.mvc.viewusercontrol<ipaginated>" %> 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -