开发者

Overriding default ASP.Net MVC scaffolding HTML

Each time I use Visual Studio to generate a 开发者_StackOverflow中文版display-template using scaffolding I get something like this:

<fieldset>
    ...
    <div class="display-label">Property</div>
    <div class="display-field">@Model.Property</div>
    ...
</fieldset>

Is there any way to change this template so that it use a HTML definition list instead?

<dl>
    ...
    <dt>Property</dt>
        <dd>@Model.Property</dd>
    ...
</dl>

I know you could use DisplayTemplates, but I want the generated code to be default in all my projects.


Take a look at the following post: http://weblogs.asp.net/scottgu/archive/2009/01/27/asp-net-mvc-1-0-release-candidate-now-available.aspx. It describes customizing the templates. While it was written about Mvc 1 everything still applies


If you are having trouble finding the item templates you can add them to your project with Nuget: http://blogs.msdn.com/b/joecar/archive/2011/01/06/add-the-asp-net-mvc-3-code-templates-to-your-application-with-nuget.aspx


You can accomplish this through T4 templates. Take a look at the explanation in this thread. How do I create my own Scaffold Template in ASP.NET MVC 3?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜