首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >不能动态调度Html.ActionLink

不能动态调度Html.ActionLink
EN

Stack Overflow用户
提问于 2011-04-29 21:29:35
回答 1查看 23.8K关注 0票数 56

我对MVC3有个问题

我正在尝试使用@Html.ActionLink()为我的博客项目中的标题生成一个链接。

ActionLink中使用常量字符串非常好用,但是如果我使用Posts.Title (正在循环的当前Post模型的标题),我会得到这个异常:

代码语言:javascript
复制
CS1973: 'System.Web.Mvc.HtmlHelper<dynamic>' has no applicable method 
named 'ActionLink' but appears to have an extension method by that name.  
Extension methods cannot be dynamically dispatched. Consider casting  
the dynamic arguments or calling the extension method without the  
extension method syntax.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-04-29 21:31:51

“考虑强制转换动态参数或调用不使用扩展方法语法的扩展方法。”

Posts.Title没有类型(因此是动态参数)。

只需通过(字符串)Posts.Title转换它。

票数 108
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5832692

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档