1
0
mirror of https://github.com/rudollee/LearningMVC.git synced 2026-08-11 16:32:55 +00:00

Ch. 22 Templated Helper Methods

This commit is contained in:
wook
2017-04-18 01:52:16 +09:00
parent 1eb39e5afc
commit dabe7ab03e
10 changed files with 147 additions and 9 deletions
+23 -7
View File
@@ -3,37 +3,53 @@
@{
ViewBag.Title = "CreatePerson";
Layout = "/Views/Shared/_Layout.cshtml";
Html.EnableClientValidation(false);
}
<h2>CreatePerson</h2>
<h2>CreatePerson @Html.LabelForModel() </h2>
@*@{ Html.BeginForm();}*@
@using (Html.BeginRouteForm("FormRoute", new { }, FormMethod.Post,
new { @class = "personClass", data_formtype = "person" }))
new { @class = "personClass", data_formtype = "person" }))
{
<div class="column">
@Html.EditorForModel()
</div>
<div class="column">
@Html.EditorFor(m => m.HomeAddress)
</div>
<!--
<div class="dateElem">
<label>PersonId</label>
@*<input name="personId" value="@Model.PersonId" />*@
@*@Html.TextBox("personId", @Model.PersonId)*@
@Html.TextBoxFor(m => m.PersonId)
@*@Html.TextBoxFor(m => m.PersonId)*@
@* @Html.Editor("PersonId")*@
</div>
<div class="dateElem">
<label>First Name</label>
@*<input name="FirstName" value="@Model.FirstName" />*@
@*@Html.TextBox("FirstName", @Model.FirstName)*@
@Html.TextBoxFor(m => m.FirstName)
@*@Html.TextBoxFor(m => m.FirstName)*@
@* @Html.Editor("FirstName")*@
</div>
<div class="dateElem">
<label>Last Name</label>
@*<input name="LastName" value="@Model.LastName" />*@
@*@Html.TextBox("LastName", @Model.LastName)*@
@Html.TextBoxFor(m => m.LastName)
@*@Html.TextBoxFor(m => m.LastName)*@
@* @Html.EditorFor(m => m.LastName)*@
</div>
<div class="dateElem">
<label>Role</label>
@Html.DropDownListFor(m => m.Role, new SelectList(Enum.GetNames(typeof(HelperMethods.Models.Role))))
@* @Html.DropDownListFor(m => m.Role, new SelectList(Enum.GetNames(typeof(HelperMethods.Models.Role))))*@
@*@Html.EditorFor(m => m.Role)*@
</div>
<div class="dateElem">
<label>Birth Date</label>
@*@Html.EditorFor(m => m.BirthDate)*@
</div>
-->
<input type="submit" value="Submit" />
}
@@ -0,0 +1,28 @@
@model HelperMethods.Models.Person
@{
ViewBag.Title = "DisplayPerson";
Layout = "/Views/Shared/_Layout.cshtml";
}
<h2>DisplayPerson</h2>
<div class="dateElem">
@Html.Label("PersonId")
@Html.Display("PersonId")
</div>
<div class="dateElem">
@Html.Label("FirstName")
@Html.Display("FirstName")
</div>
<div class="dateElem">
@Html.LabelFor(m => m.LastName)
@Html.DisplayFor(m => m.LastName)
</div>
<div class="dateElem">
@Html.LabelFor(m => m.Role)
@Html.DisplayFor(m => m.Role)
</div>
<div class="dateElem">
@Html.LabelFor(m => m.BirthDate)
@Html.DisplayFor(m => m.BirthDate)
</div>