, , 2 - .
- EditorTemplates.
aka Personal, Address, Overal.
( ) Overal Get, View Post, .
public ActionResult Index()
{
var model = new OveralModel();
return View(model);
}
[HttpPost]
public ActionResult Index(OveralModel model)
{
return View(model);
}
( )
@model EditorFor.Models.OveralModel
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>OverallModel</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(m => m.Id)
<div>
@Html.EditorFor(m => m.Personal)
</div>
<div>
@Html.EditorFor(m => m.Address)
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}
PartialView EditorModels, PartialView, , .
, , EditorTemplates Views/Shared Views , .
EditorTemplate PersonalModel PersonalModel.cshtml, .
@model EditorFor.Models.PersonelModel
<div class="form-group">
@Html.LabelFor(model => model.FirstName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.FirstName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.LastName, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.LastName, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.LastName, "", new { @class = "text-danger" })
</div>
</div>
, sou @Html.EditorFor(m => m.Personal), EditorTemplates EditorTemplate .
"",
, , , .
PS: , , .