2. 이번에는 게시판의 글쓰기 페이지에 포함되어 실행되는 부분 페이지인 글쓰기 폼을 구성해보자. Views 폴더의 DotNetNote 폴더에 _BoardEditorForm.cshtml 뷰 페이지를 생성하고, 다음과 같이 코드를 작성한다. 글쓰기 폼은 글쓰기, 글수정, 글답변, 세 페이지에서 사용하다 보니 _BoardEditorForm.cshtml 페이지로 입력 폼의 모양을 설정해 공통적인 폼의 모양을 만들었다.
▼ /Views/DotNetNote/_BoardEditorForm.cshtml
@model Note
<div class=“form-horizontal”>
@if (ViewBag.FormType == DotNetNote.Models.BoardWriteFormType.Modify)
{
<div class=“form-group”>
<label asp-for=“Id” class=“col-md-2 control-label”></label>
<div class=“col-md-10”>
<input asp-for=“Id” class=“form-control”
style=“border:0; width:100px;” maxlength=“10” readonly />
<input type=“hidden” name=“Id” value=”@Model.Id” />
</div>
</div>
}
<div class=“form-group”>
<label asp-for=“Name” class=“col-md-2 control-label”></label>
<div class=“col-md-10”>
<input asp-for=“Name” class=“form-control”
style=“width:150px;” maxlength=“10” />
<span asp-validation-for=“Name” class=“text-danger”></span>
</div>
</div>
<div class=“form-group”>
<label asp-for=“Email” class=“col-md-2 control-label”></label>
<div class=“col-md-10”>
<input asp-for=“Email” class=“form-control”
style=“width:200px;display:inline-block;” maxlength=“80” />
<span style=“color:#aaaaaa;font-style:italic”>(Optional)</span>
<span asp-validation-for=“Email” class=“text-danger”></span>
</div>
</div>
<div class=“form-group”>
<label asp-for=“Homepage” class=“col-md-2 control-label”></label>
<div class=“col-md-10”>
<input asp-for=“Homepage” class=“form-control”
style=“width:300px;display:inline-block;” maxlength=“80” />
<span style=“color:#aaaaaa;font-style:italic”>(Optional)</span>
<span asp-validation-for=“Homepage” class=“text-danger”></span>
</div>
</div>
<div class=“form-group”>
<label asp-for=“Title” class=“col-md-2 control-label”></label>
<div class=“col-md-10”>
<input asp-for=“Title” class=“form-control” style=“width:480px;” />
<span asp-validation-for=“Title” class=“text-danger”></span>
</div>
</div>
<div class=“form-group”>
<label asp-for=“Content” class=“col-md-2 control-label”></label>
<div class=“col-md-10”>
<textarea asp-for=“Content” class=“form-control”
style=“width:480px;height:100px;” rows=“5” cols=“80”></textarea>
<span asp-validation-for=“Content” class=“text-danger”></span>
</div>
</div>
<div class=“form-group”>
<label asp-for=“FileName” class=“col-md-2 control-label”></label>
<div class=“col-md-10”>
<input type=“file” name=“files” value=””
style=“width:290px; display:inline-block;” />
<span style=“color:#aaaaaa;font-style:italic”>(Optional)</span>
<span asp-validation-for=“FileName” class=“text-danger”></span>
@if (ViewBag.FileSize > 0)
{
<br />
@ViewBag.FileNamePrevious
}
<input type=“hidden” name=“previousFileName”
value=”@ViewBag.FileName” />
<input type=“hidden” name=“previousFileSize”
value=”@ViewBag.FileSize” />
</div>
</div>
<div class=“form-group”>
<label asp-for=“Encoding” class=“col-md-2 control-label”></label>
<div class=“col-md-10”>
<select asp-for=“Encoding” class=“form-control”
style=“width:100px;”>
<option value=“Text” selected>Text</option>
<option value=“Html”>HTML</option> @대소문자 구분 주의@
<option value=“Mixed”>Mixed</option>
</select>
</div>
</div>
<div class=“form-group”>
<label asp-for=“Password” class=“col-md-2 control-label”></label>
<div class=“col-md-10”>
<input asp-for=“Password” type=“password” class=“form-control”
style=“width:150px;display:inline-block;” maxlength=“20” />
<span style=“color:#aaaaaa;”>(수정/삭제시에 필요)</span><br />
<span asp-validation-for=“Password” class=“text-danger”></span>
</div>
</div>
<div class=“col-md-offset-2 col-md-10”>
<input type=“submit” value=”@ViewBag.SaveButtonText”
class=“btn btn-primary” />
<a asp-action=“Index” class=“btn btn-default”>리스트</a>
<div asp-validation-summary=“ModelOnly” class=“text-danger”></div>
<span class=“text-danger”>@ViewBag.ErrorMessage</span>
</div>
</div>
@Category 기본값은 Free(자유 게시판)로 설정@
<input type=“hidden” asp-for=“Category” value=“Free” />