Many MVC extensions use their own variable for the HtmlHelper
on the view page, like you would mark up a Telerik helper as @Telerik().Helper
. My extension is still stuck on the ol' HtmlHelper<TModel>
, so I can't say @Erisia().Helper
and have to resort to plain old, non-promotional, @Html.MyHelper
.
许多MVC扩展在视图页面上为HtmlHelper使用它们自己的变量,就像你将Telerik助手标记为@Telerik()。帮助器一样。我的扩展程序仍然停留在ol'HtmlHelper
How can I achieve this trick like other extension libraries?
我怎样才能像其他扩展库一样实现这个技巧?
1 个解决方案
#1
1
You can just make your own static class for this
你可以为此创建自己的静态类
public static class Test
{
public static string Helper()
{
return "helper!";
}
}
And then in your view @Test.Helper
然后在你的视图@ Test.Helper中
See this question if you need to inherit from HtmlHelper for some reason.
如果由于某种原因需要继承HtmlHelper,请参阅此问题。
#1
1
You can just make your own static class for this
你可以为此创建自己的静态类
public static class Test
{
public static string Helper()
{
return "helper!";
}
}
And then in your view @Test.Helper
然后在你的视图@ Test.Helper中
See this question if you need to inherit from HtmlHelper for some reason.
如果由于某种原因需要继承HtmlHelper,请参阅此问题。