2010-02-09 60 views
0

我有一个stongly类型的视图:强类型视图使用的html助手的正确语法是什么?

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

我试图使用它的HTML帮手在非强类型的视图正常工作。我已经尝试了一些变化,如:

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"; 
} 

尝试:

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

我得到类似的消息:

'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 

什么是正确的语法?

[这是在MVC2 RC]

回答

0

新手的错误 - 只是忘了导入我的命名空间在web.config中。

备案,无论是工作:

<%=Html.Pager1() %> 
<%=Html.Pager1<IPagedList<Product>>() %> 
相关问题