在 MVC 中,当我们需要像下面这样的表单来创建我的模型的新项目时,我们使用创建脚手架模板模型在模型上添加一个强类型视图:
public class book
{
[Key]
public int BId { get; set; }
[Display(Name = "نام")]
public string name { get; set; }
[Display(Name = "نویسنده")]
public string writer { get; set; }
[Display(Name = "ناشر")]
public string publisher { get; set; }
[Display(Name = "سال انتشار")]
public string year { get; set; }
} `
结果是这样的:
@model مدرسه.Models.book
`@{
ViewBag.Title = "BookStore";
} `
` <h2>BookStore</h2>`
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>book</legend>
<div class="editor-label">
@Html.LabelFor(model => model.name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.name)
@Html.ValidationMessageFor(model => model.name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.writer)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.writer)
@Html.ValidationMessageFor(model => model.writer)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.publisher)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.publisher)
@Html.ValidationMessageFor(model => model.publisher)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.year)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.year)
@Html.ValidationMessageFor(model => model.year)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
`}`
<div>
@Html.ActionLink("Back to List", "Index")
</div>
`@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
} `
此模板遵循以下路径:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding
我需要了解如何更改此文件,实际上该文件是什么以及更改模板的部分是什么?