mvc html helper

main
syneffort 2 years ago
parent 476a678d12
commit e410809b9d
  1. 1
      AspNetFrameworkMVC/AspNetFrameworkMVC/AspNetFrameworkMVC.csproj
  2. 8
      AspNetFrameworkMVC/AspNetFrameworkMVC/Controllers/HomeController.cs
  3. 3
      AspNetFrameworkMVC/AspNetFrameworkMVC/Models/Guest.cs
  4. 26
      AspNetFrameworkMVC/AspNetFrameworkMVC/Views/Home/Guest.cshtml

@ -194,6 +194,7 @@
<Content Include="Views\Home\MyViewRazor.cshtml" />
<Content Include="Views\Home\GuestRazor.cshtml" />
<Content Include="Views\Home\ShowGuests.cshtml" />
<Content Include="Views\Home\Guest.cshtml" />
</ItemGroup>
<ItemGroup />
<ItemGroup>

@ -145,5 +145,13 @@ namespace AspNetFrameworkMVC.Controllers
return View(guests);
}
public ActionResult Guest(int id)
{
var db = new GuestDbContext();
Guest guest = db.Guests.Where(g => g.Id == id).FirstOrDefault();
return View(guest);
}
}
}

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
@ -12,6 +13,8 @@ namespace AspNetFrameworkMVC.Models
{
public int Id { get; set; }
public string Name { get; set; }
[Display(Name="작성일자")]
[DisplayFormat(DataFormatString="{0:yyyy-MM-dd}")]
public DateTime CreatedDate { get; set; }
public string Message { get; set; }
}

@ -0,0 +1,26 @@
@model AspNetFrameworkMVC.Models.Guest
@{
ViewBag.Title = "Guest Details";
}
@if (Model == null)
{
<p>
해당 사용자를 찾을 수 없습니다.
</p>
return;
}
<p>
@Html.TextBox("Name", null, new {@class = "form-control"})
<br/>
@Html.TextBoxFor(g => g.Message, new { @class = "form-control" })
<br/>
Id: @Html.DisplayTextFor(g => g.Id)
<br/>
@Html.LabelFor(g => g.CreatedDate)
@Html.DisplayFor(g => g.CreatedDate)
</p>
Loading…
Cancel
Save