How do I edit default Razor Creat/Edit scaffolding in Visual Studio 2010

与世无争的帅哥 提交于 2020-01-12 08:52:10

问题


is there a way I can hack out the fieldset and legend tags in the VS2010 MVC razor view templates?

I've had a bit of a look through the C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE directory but I can't find what I'm looking for.


回答1:


If it is specific to your project, what you can do is copy the default templates to  your project and modify them.

The MVC razor view templates are located in:

<Visual Studio Installation Path>\Common7\IDE\ItemTemplates\CSharp\Web\MVC 3\CodeTemplates
\AddView\CSHTML\
  1. Copy the .tt files

  2. Create a matching folder tree in your project starting from CodeTemplates. In this case,  you need to create \CodeTemplates\AddView\CSHTML\ and paste the .tt files there.

  3. Now you can edit the .tt files as you want. When you crete a new view in that project, those templates will  be used instead of the default ones from the installation folder. That also works for the controller templates, you just have to make sure that the folder  tree matches.



回答2:


Sounds like you'll need to download the source for MVC 3.0 and copy the templates you want to overwrite into you project and make the changes there.



来源:https://stackoverflow.com/questions/6894077/how-do-i-edit-default-razor-creat-edit-scaffolding-in-visual-studio-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!