开发者

Calling HtmlHelper's extension method from within a PartialView

I'm trying to call a custom HtmlHelper's extension method f开发者_运维技巧rom a partial view

<%: Html.ToRelativeTime(Model.CreatedDate) %>

and I get this error:

CS1061: ...does not contain a definition for 'ToRelativeTime' and no extension method 'ToRelativeTime' accepting a first argument of type 'System.Web.Mvc.HtmlHelper...could be found (are you missing a using directive or an assembly reference?)

and I'm calling the render code as this:

<% Html.RenderPartial("Product", Model.Product); %>

P.S: When I type Html., there is no intellesince.


Try to add namespace reference of your extension to the partial view where you trying to use your custom extension

<%@ import namespace='your namespace' %>

also here you may find a useful information

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜