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]