从 PartialView 中调用 HtmlHelper 的扩展方法
我试图从部分视图调用自定义 HtmlHelper 的扩展方法
<%: Html.ToRelativeTime(Model.CreatedDate) %>
,但收到此错误:
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?)
并且我调用渲染代码如下:
<% Html.RenderPartial("Product", Model.Product); %>
PS:当我输入 Html.
时,没有智能。
I'm trying to call a custom HtmlHelper's extension method from 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将扩展的命名空间引用添加到您尝试使用自定义扩展的部分视图
这里您可能会找到有用的信息
Try to add namespace reference of your extension to the partial view where you trying to use your custom extension
also here you may find a useful information