是否有人可以建议是否可以在新的自定义 Html 帮助器中重新使用现有的 HtmlHelper。例如:
public static class GridHelper
{
public static string RenderGrid(this HtmlHelper helper, Object routeParams)
{
return HtmlHelper.BeginForm(routeParams);
}
}
上面是一个简单的例子,但本质上我想为一组渲染 View 的 html 助手分组一些逻辑和格式。这个 View 将在几个地方使用,因此我想重新使用代码。然而,在我目前的所有尝试中,我一直无法访问像“CheckBox”或“BeginForm”这样的方法。也许我没有正确使用 HtmlHelper 对象?
有谁知道这是否可以做到?
谢谢,马特
请您参考如下方法:
在您的示例中,我认为您需要执行以下操作:
public static class GridHelper
{
public static string RenderGrid(this HtmlHelper helper, Object routeParams)
{
return helper.BeginForm(routeParams);
}
}
