几天前我发现了 NHaml,这是一个很棒的项目。
当我尝试使用 MVC2 Html 助手时,如Html.LabelFor(),Html.TextBoxFor();视图不会编译。
例子:
error CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'LabelFor' and no extension method 'LabelFor' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
0185: textWriter.Write(" ");
0185: textWriter.Write(Convert.ToString(Html.LabelFor(model => model.Username)));
0187: textWriter.WriteLine();
error CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'TextBoxFor' and no extension method 'TextBoxFor' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
0194: textWriter.Write(" ");
0194: textWriter.Write(Convert.ToString(Html.TextBoxFor(model => model.Username)));
0196: textWriter.WriteLine();
我试图在 naml 的 Web.config 部分中添加程序集和命名空间,但它并没有改变任何东西。
我在用着 :
- 系统.Web.Mvc 2.0
- .NET 框架 3.5 SP1
- 来自 git trunk 的 Nhaml 1.5.0.2(并尝试了其他构建)
我的 NHaml 配置是:
<nhaml autoRecompile="true" templateCompiler="CSharp3" encodeHtml="false" useTabs="false" indentSize="2">