我希望有人能帮助我。我一直在尝试为我的 MVC 应用程序编写一个自定义的 html 帮助程序。首先,我尝试了一个测试,它只写了一个
指定参数的标记。问题是,除非我明确导入命名空间,否则它不起作用。我读了很多书,当我读到时,该方法应该没有像这样的导入命名空间出现:
<%=Html.Prueba("This is a paragraph") %>
但是这种方法 Prueba 并没有出现在 VS Intellisense 中。
我的班级如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
namespace EasyGoCostaRica.Helpers
{
public static class ViewsHelpers
{
//This method is just for testing. Is not working :(
public static string Prueba(this HtmlHelper helper, string param1)
{
return string.Format("<p>{0}</p>", param1);
}
}
}
提前致谢!