I'm looking to build an reusable control or custom helper for my MVC project. I'm sure there is a best practice for this. Any help is appreciated.
我正在寻找为我的MVC项目构建可重用的控件或自定义帮助器。我确信这是最好的做法。任何帮助表示赞赏。
2 个解决方案
#1
8
Sure, the best practices are encapsulated in the HtmlHelpers and other helpers in the MVC source code. You can get the source at http://www.codeplex.com/aspnet
当然,最佳实践封装在HtmlHelpers和MVC源代码中的其他帮助程序中。您可以从http://www.codeplex.com/aspnet获取源代码
#2
0
(Hate to disagree with you Scott) Using HtmlHelpers is not a best practice. It is not a practice that has been sharpened through use on real projects and is only one approach. I have recently written a little post on using SubControllers.. we use HtmlHelpers for some small things, but we use SubControllers for greater control, composition and dependency inversion.
(讨厌不同意你斯科特)使用HtmlHelpers不是最好的做法。通过在实际项目中使用而不是一种实践,这只是一种方法。我最近写过一篇关于使用SubControllers的文章。我们使用HtmlHelpers来处理一些小事情,但是我们使用SubControllers来实现更好的控制,组合和依赖性反转。
#1
8
Sure, the best practices are encapsulated in the HtmlHelpers and other helpers in the MVC source code. You can get the source at http://www.codeplex.com/aspnet
当然,最佳实践封装在HtmlHelpers和MVC源代码中的其他帮助程序中。您可以从http://www.codeplex.com/aspnet获取源代码
#2
0
(Hate to disagree with you Scott) Using HtmlHelpers is not a best practice. It is not a practice that has been sharpened through use on real projects and is only one approach. I have recently written a little post on using SubControllers.. we use HtmlHelpers for some small things, but we use SubControllers for greater control, composition and dependency inversion.
(讨厌不同意你斯科特)使用HtmlHelpers不是最好的做法。通过在实际项目中使用而不是一种实践,这只是一种方法。我最近写过一篇关于使用SubControllers的文章。我们使用HtmlHelpers来处理一些小事情,但是我们使用SubControllers来实现更好的控制,组合和依赖性反转。