From 2047c92b961898537d87e5e0a1a79415eea5bad2 Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Thu, 23 Sep 2021 16:29:18 +1000 Subject: [PATCH] 11.1.4.2 Creating the Edit View; Listing 11-8 Updating the `Edit.cshtml` File --- .../SportsStore.WebUI/Views/Admin/Edit.cshtml | 46 +++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/SportsStore/SportsStore.WebUI/Views/Admin/Edit.cshtml b/SportsStore/SportsStore.WebUI/Views/Admin/Edit.cshtml index 9c7bbd8..6d7c0f7 100644 --- a/SportsStore/SportsStore.WebUI/Views/Admin/Edit.cshtml +++ b/SportsStore/SportsStore.WebUI/Views/Admin/Edit.cshtml @@ -1,15 +1,45 @@ @model SportsStore.Domain.Entities.Product @{ - ViewBag.Title = "Edit"; + ViewBag.Title = "Admin: Edit" + Model.Name; Layout = "~/Views/Shared/_AdminLayout.cshtml"; } -

Edit @Model.Name

+
+
+

Edit @Model.Name

+
+ + @using (Html.BeginForm()) + { +
+ @Html.HiddenFor(m => m.ProductID) + @foreach (var property in ViewData.ModelMetadata.Properties) + { + if (property.PropertyName != "ProductID") + { +
+ + @if (property.PropertyName == "Description") + { + @Html.TextArea(property.PropertyName, null, + new { @class = "form-control", rows = 5 }) + } + else + { + @Html.TextBox(property.PropertyName, null, + new { @class = "form-control" }) + } +
+ } + } +
+ + + } +
-@using (Html.BeginForm()) -{ - @Html.EditorForModel() - - @Html.ActionLink("Cancel and return to List", "List") -}