与App_Code不同的文件夹中的Asp.Net MVC @helper模板 [英] Asp.Net MVC @helper template in different folder than App_Code
本文介绍了与App_Code不同的文件夹中的Asp.Net MVC @helper模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
就像我在问题标题中所说的那样,是否可以将cshtml文件的@helper模板放在App_Code之外的其他文件夹中以使视图可见?
Like I said in the title of my question, is it possible to put the @helper template of cshtml file in a folder other than App_Code to be visible by my views?
I discovered the very nice article from ScottGu but I don't found any solution to my question.
谢谢.
推荐答案
如果将它们编写为扩展方法(静态类的静态方法),则可以.像这样:
You can, if you write them as extension methods (static methods of a static class). Something like:
public static string AMethod(this HtmlHelper html, int arg)
...
让您将cshtml文件中的方法称为
Lets you call the method in a cshtml file as
@Html.AMethod(5)
这篇关于与App_Code不同的文件夹中的Asp.Net MVC @helper模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文