2010-02-09 5 views
0

J'ai vue stongly tapé:Quelle est la syntaxe correcte pour un helper html utilisé par une vue fortement typée?

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IPagedList<Product>>" %> 

Je suis en train d'utiliser un assistant HTML sur ce qui fonctionne bien sur une vue non fortement typé. J'ai essayé quelques variations, telles que:

public static string Pager(this HtmlHelper helper) 
{ 
    //works great from non-strongly typed views 
    return "Pager"; 
} 

public static string Pager1<TModel>(this HtmlHelper<TModel> helper) 
{ 
    //might work for a stongly typed view? 
    return "Pager1"; 
} 

Essayé:

<%=Html.Pager() %> 
<%=Html.Pager1() %> 
<%=Html.Pager1<IPagedList<Product>>() %> 

Je reçois des messages similaires:

'System.Web.Mvc.HtmlHelper<WillowCore.Common.IPagedList<Willow.Domain.BI.Product>>' does not contain a definition for 'Pager1' and no extension method 'Pager1' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<WillowCore.Common.IPagedList<Willow.Domain.BI.Product>>' could be found 

Quelle est la syntaxe correcte?

[C'est sous MVC2 RC]

Répondre

0

recrue erreur - a juste oublié d'importer mon espace de noms dans le web.config.

pour l'enregistrement, soit le travail:

<%=Html.Pager1() %> 
<%=Html.Pager1<IPagedList<Product>>() %> 
Questions connexes