3. Views 폴더의 CommunityCamp 폴더에 Create.cshtml이라는 이름으로 뷰 페이지를 생성하고, 다음과 같이 코드를 작성한다. CommunityName에는 <option> 태그를 사용해 두 커뮤니티 이름을 입력했다. 폼 유효성 검사를 위해서 _ValidationScriptsPartial.cshtml 페이지를 Scripts 섹션에 추가하는 코드가 반드시 들어와야 한다. 앞서 이미 만들어 놓은 _ValidationScriptsPartial.cshtml 파일은 Views 폴더의 Shared 폴더에 위치한다.
▼ /Views/CommunityCamp/Create.cshtml
@using DotNetNote.Models
@{
ViewData[“Title”] = “커뮤니티 캠프”;
}
@model CommunityCampJoinMember
<h2>등록하기</h2>
@section Scripts {
@{ await Html.RenderPartialAsync(“_ValidationScriptsPartial”); }
}
<form asp-controller=“CommunityCamp” asp-action=“Create” method=“post”
class=“form-horizontal”>
<div asp-validation-summary=“ModelOnly”></div>
<div class=“form-group”>
<label asp-for=“CommunityName” class=“col-sm-2 control-label”></label>
<div class=“col-sm-10”>
<select asp-for=“CommunityName” class=“form-control”>
<option value=“ASP.NET Korea”>ASP.NET Korea</option>
<option value=“Taeyo.NET”>Taeyo.NET</option>
</select>
</div>
</div>
<div class=“form-group”>
<label asp-for=“Name” class=“col-sm-2 control-label”></label>
<div class=“col-sm-10”>
<input asp-for=“Name” class=“form-control” />
<span asp-validation-for=“Name” class=“text-danger”></span>
</div>
</div>
<div class=“form-group”>
<label asp-for=“Mobile” class=“col-sm-2 control-label”></label>
<div class=“col-sm-10”>
<input asp-for=“Mobile” class=“form-control” />
<span asp-validation-for=“Mobile” class=“text-danger”></span>
</div>
</div>
<div class=“form-group”>
<label asp-for=“Email” class=“col-sm-2 control-label”></label>
<div class=“col-sm-10”>
<input asp-for=“Email” class=“form-control” />
<span asp-validation-for=“Email” class=“text-danger”></span>
</div>
</div>
<div class=“form-group”>
<label asp-for=“Size” class=“col-sm-2 control-label”></label>
<div class=“col-sm-10”>
<select asp-for=“Size” class=“form-control”>
<option value=“S”>S</option>
<option value=“M”>M</option>
<option value=“L”>L</option>
<option value=“XL”>XL</option>
<option value=“2XL”>2XL</option>
<option value=“3XL”>3XL</option>
</select>
</div>
</div>
<div class=“form-group”>
<div class=“col-md-offset-2 col-md-10”>
<input type=“submit” name=“btnSave” value=“등록”
class=“btn btn-primary btn-lg” />
<a asp-controller=“CommunityCamp” asp-action=“Index”
class=“btn btn-default btn-sm”>취소</a>
</div>
</div>
</form>
@if (ViewBag.Result != null)
{
<div>
@ViewBag.Result
</div>
}