mirror of
https://github.com/rudollee/LearningMVC.git
synced 2026-08-11 16:32:55 +00:00
Ch. 21 Helper Methods
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
@model HelperMethods.Models.Person
|
||||
|
||||
@{
|
||||
ViewBag.Title = "CreatePerson";
|
||||
Layout = "/Views/Shared/_Layout.cshtml";
|
||||
}
|
||||
|
||||
<h2>CreatePerson</h2>
|
||||
|
||||
@*@{ Html.BeginForm();}*@
|
||||
@using (Html.BeginRouteForm("FormRoute", new { }, FormMethod.Post,
|
||||
new { @class = "personClass", data_formtype = "person" }))
|
||||
{
|
||||
|
||||
<div class="dateElem">
|
||||
<label>PersonId</label>
|
||||
@*<input name="personId" value="@Model.PersonId" />*@
|
||||
@*@Html.TextBox("personId", @Model.PersonId)*@
|
||||
@Html.TextBoxFor(m => m.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)
|
||||
</div>
|
||||
<div class="dateElem">
|
||||
<label>Last Name</label>
|
||||
@*<input name="LastName" value="@Model.LastName" />*@
|
||||
@*@Html.TextBox("LastName", @Model.LastName)*@
|
||||
@Html.TextBoxFor(m => m.LastName)
|
||||
</div>
|
||||
<div class="dateElem">
|
||||
<label>Role</label>
|
||||
@Html.DropDownListFor(m => m.Role, new SelectList(Enum.GetNames(typeof(HelperMethods.Models.Role))))
|
||||
</div>
|
||||
<input type="submit" value="Submit" />
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
@model string
|
||||
@using HelperMethods.Infrastructure
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
|
||||
@*@helper ListArrayItems(string[] items)
|
||||
{
|
||||
<ul>
|
||||
@foreach (string str in items)
|
||||
{
|
||||
<li>@str</li>
|
||||
}
|
||||
</ul>
|
||||
}*@
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<title>Index</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
Here are the fruits: @Html.ListArrayItems((string[])ViewBag.Fruits) @*@ListArrayItems(ViewBag.Fruits)*@
|
||||
@*@foreach (string str in (string[])ViewBag.Fruits)
|
||||
{
|
||||
<b>@str</b>
|
||||
}*@
|
||||
</div>
|
||||
<div>
|
||||
Here are the cities: @Html.ListArrayItems((string[])ViewBag.Cities) @*@ListArrayItems(ViewBag.Cities)*@
|
||||
@*@foreach (string str in (string[])ViewBag.Cities)
|
||||
{
|
||||
<b>@str</b>
|
||||
}*@
|
||||
</div>
|
||||
<div style="border: thin solid black; padding: 10px;">
|
||||
Here is the message:
|
||||
<p>@Model</p>
|
||||
</div>
|
||||
|
||||
<p>This is the content from the helper method:</p>
|
||||
<div style="border: thin solid black; padding: 10px;">
|
||||
@Html.DisplayMessage(Model)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user