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
精彩评论