开发者

change how mvc3 razor renders a newly created view

开发者 https://www.devze.com 2023-02-12 14:18 出处:网络
By default whenever you create a strongly typed \"Insert Type\" view using mvc3 razor it renders the html similar to

By default whenever you create a strongly typed "Insert Type" view using mvc3 razor it renders the html similar to

       <div class="editor-label">
        @Html.LabelFor(model => model.Email)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.Email)
        @Html.ValidationMessageFor(model 开发者_JS百科=> model.Email)
    </div>

Which is inside a fieldset. I don't really want this behavior is it possible to replace the default style of html to my own? I dont want fieldsets and I want to remove the css class details for the div tags as I think its a little of an overkill for what I need.

Any suggestions would be great


You could modify the corresponding T4 templates. For example on my machine they are located in the following folder:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 3\CodeTemplates\AddView\CSHTML\

Modifying them would be global for the machine.

You can also modify/add new them per project. So in your project you could create the following folder:

~/CodeTemplates/AddView/CSHTML/Edit.tt
0

精彩评论

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