我通过
his blog看到了Scott Guthrie关于助手方法的帖子.
具体来说:
我看到一堆RC版本的MVC 3帖子关于缺少辅助方法…我看到它的语法支持(@helper)突出显示,但我在/Views/Helpers/SomeHelper.cshtml中有这个(定义为局部视图):
- @helper SomeHelper(string text)
- {
- if (text != null)
- {
- <text>
- @text
- </text>
- }
- else
- {
- <text>
- Unknown
- </text>
- }
- }
我这样使用它:
- <div>
- Helper with Text:
- @SomeHelper("This is not null text.")
- </div>
但我得到SomeHelper没有定义….所以我把它搞得一团糟?我是否需要做些什么来将这些视图注册为帮助者?
谢谢.