开发者

Calling HtmlHelper's extension method from within a PartialView

开发者 https://www.devze.com 2023-04-02 08:30 出处:网络
I\'m trying to call a custom HtmlHelper\'s extension method f开发者_运维技巧rom a partial view

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

精彩评论

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