What is the correct syntax for an html helper used by a strongly typed view?
I have a stongly typed view:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IPagedList<Product>>" %>
I'm trying to use an HTML helper on it that works fine on a non-strongly typed view. I've tried a few variations, such as:
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";
}
Tried:
<%=Html.Pager() %>
<%=Html.Pager1() %>
<%=Html.Pager1<IPagedList<Product>>() %>
I get similar messages:
'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
What is the correct syntax?
[This is under MVC2 RC]
rookie mistake -- just forgot to import my namespace in the web.config.
for the record, either work:
<%=Html.Pager1() %>
<%=Html.Pager1<IPagedList<Product>>() %>
精彩评论