Part 54 - T4 templates in asp.net mvc
来源:互联网 发布:java web入门教程 编辑:程序博客网 时间:2024/05/18 20:06
1. What are T4 templates and their purpose
2. Customizing T4 templates
What are T4 templates and their purpose?
T4 stands for Text Template Transformation Toolkit and are used by visual studio to generate code when you add a view or a controller.
Where does these T4 templates live?
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\[CSharp | FSharp | VisualBasic]\Web\[MVC 2 | MVC 3 | MVC 4]\CodeTemplates
What is the file extension for T4 templates?
.tt
Is it possible to customize T4 templates?
Yes, T4 templates can be customized in place, if you want the customized T4 templates available for all MVC projects on that machine.
If you want to customize T4 templates, only for a specific project, then copy"CodeTemplates" folder and paste it in the root directory of your MVC project. Right click on the template files(with .tt extension), and select Properties and delete"TextTemplatingFileGenerator".
By deleting this from CustomTool property, we are telling visual studio not to run them during the build. They will be manually called when we add a view or a controller using"Add View" and "Add Controller" dialog box.
Is it possible to add your own T4 template to the existing list of templates?
Absolutely, simply create a file with ".tt" file extension in "AddController" folder in"CodeTemplates". If it is for adding a view, then put it in "AspxCSharp"(if view engine is aspx) or "CSHTML"(if view engine is razor) folder.
- Part 54 - T4 templates in asp.net mvc
- T4 Templates: A Quick-Start Guide for ASP.NET MVC Developers
- Part 60 - ViewStart in asp.net mvc
- Part 86 - ValidationSummary in asp.net mvc
- Understanding Templates in ASP.NET
- Part 2 - View engines in asp.net mvc
- Part 81 - Range attribute in asp.net mvc
- Part 82 - Creating custom validation attribute in asp.net mvc
- Part 83 - RegularExpression attribute in asp.net mvc
- Part 84 - Compare attribute in asp.net mvc
- Part 85 - Enable client side validation in asp.net mvc
- Part 88 - Unobtrusive validation in asp.net mvc
- Part 89 - Remote validation in asp.net mvc
- T4 模板: 为 ASP.NET MVC 开发人员快速入门指南
- T4 模板 : 一种提升ASP.NET MVC开发速度方法
- ASP.NET MVC Framework (Part 1)
- 【转】ASP.NET MVC Framework (Part 1)
- 【转】ASP.NET MVC Framework (Part 1)
- 模板匹配——判断字符串是否满足模板
- Java CAS 和ABA问题
- CSS隐藏元素 display visibility opacity的区别
- 字符编码
- C语言实验——打印菱形
- Part 54 - T4 templates in asp.net mvc
- 物料帐发生业务之后再激活成本组件分割的处理方法
- Google浏览器 js调试
- hadoop 编写mapreduce测试流程
- jQuery - AJAX 简介
- 配置构建变体
- How To determine DDIC Check Table, Domain and Get Table Field Text Data For Value?
- 感谢CSDN客服~
- EasyDarwin开源摄像机访问EasyCamera中海康摄像头语音对讲和云台控制转发实现