This is a
Razor view file(Create.cshtml) responsible for rendering a form to create a new student in the web application.Let's break down its key components
@model PaginationViewModel<StudentModel>
@{
ViewData["Title"] = "Students";
}
<h1>Students</h1>
<p>
<a asp-action="Create">Create
New</a>
</p>
<form asp-action="Index" method="get">
<p>
Search: <input type="text" name="searchString" value="@ViewBag.CurrentFilter" />
<input type="submit" value="Search" />
</p>
</form>
<table class="table">
<thead>
<tr>
<th>
<a asp-action="Index" asp-route-sortOrder="@("Name" + (ViewBag.CurrentSort == "Name" ? "_desc" : ""))">Name</a>
</th>
<th>
<a asp-action="Index" asp-route-sortOrder="@("CreateDate" + (ViewBag.CurrentSort == "CreateDate" ? "_desc" : ""))">Create Date</a>
</th>
<!-- Add more table headers as needed -->
<th></th>
</tr>
</thead>
<tbody>
@foreach (var student in Model.Items)
{
<tr>
<td>@student.Name</td>
<td>@student.CreateDate.ToString()</td>
<!-- Add more table cells as needed -->
<td>
<a asp-action="Edit" asp-route-id="@student.Id">Edit</a> |
<a asp-action="Details" asp-route-id="@student.Id">Details</a> |
<a asp-action="Delete" asp-route-id="@student.Id">Delete</a>
</td>
</tr>
}
</tbody>
</table>
<nav aria-label="Page navigation">
<ul class="pagination">
@{
int pageCount =
Model.TotalPages;
int currentPage =
Model.PageIndex;
var url = Url.Action("Index", new { pageNumber = 1, pageSize =
Model.PageSize });
}
<li class="page-item
@(currentPage == 1 ? "disabled" : "")">
<a class="page-link" href="@url">First</a>
</li>
@for (int i = 1; i <= pageCount;
i++)
{
url =
Url.Action("Index", new { pageNumber = i, pageSize = Model.PageSize });
<li class="page-item @(i ==
currentPage ? "active" : "")">
<a class="page-link" href="@url">@i</a>
</li>
}
url =
Url.Action("Index", new { pageNumber = pageCount, pageSize =
Model.PageSize });
<li class="page-item
@(currentPage == pageCount ? "disabled" : "")">
<a class="page-link" href="@url">Last</a>
</li>
</ul>
</nav>
@model FreeWebApplication.Models.StudentModel
@{
ViewData["Title"] = "Edit Student";
}
<div class="container mt-5">
<h1>Edit Student</h1>
<form asp-action="Edit" method="post">
<input type="hidden" asp-for="Id" />
<div class="form-group">
<label asp-for="Name"></label>
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="EmailId"></label>
<input asp-for="EmailId" class="form-control" />
<span asp-validation-for="EmailId" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Gender"></label>
<input asp-for="Gender" class="form-control" />
<span asp-validation-for="Gender" class="text-danger"></span>
</div>
<button type="submit" class="btn btn-primary">Save</button>
<a asp-action="Index" class="btn btn-secondary">Back to List</a>
</form>
</div>
@model FreeWebApplication.Models.StudentModel
@{
ViewData["Title"] = "Student Details";
}
<div class="container mt-5">
<h1>Student Details</h1>
<dl class="row">
<dt class="col-sm-2">ID</dt>
<dd class="col-sm-10">@Model.Id</dd>
<dt class="col-sm-2">Name</dt>
<dd class="col-sm-10">@Model.Name</dd>
<dt class="col-sm-2">Email</dt>
<dd class="col-sm-10">@Model.EmailId</dd>
<dt class="col-sm-2">Gender</dt>
<dd class="col-sm-10">@Model.Gender</dd>
</dl>
<div>
<a asp-action="Index" class="btn
btn-primary">Back to List</a>
</div>
</div>
@model FreeWebApplication.Models.StudentModel
@{
ViewData["Title"] = "Student Details";
}
<div class="container mt-5">
<h1>Student Details</h1>
<dl class="row">
<dt class="col-sm-2">ID</dt>
<dd class="col-sm-10">@Model.Id</dd>
<dt class="col-sm-2">Name</dt>
<dd class="col-sm-10">@Model.Name</dd>
<dt class="col-sm-2">Email</dt>
<dd class="col-sm-10">@Model.EmailId</dd>
<dt class="col-sm-2">Gender</dt>
<dd class="col-sm-10">@Model.Gender</dd>
</dl>
<div>
<a asp-action="Index" class="btn
btn-primary">Back to List</a>
</div>
</div>
----------------------------------------------
@model FreeWebApplication.Models.StudentModel
@{
ViewData["Title"] = "Student Details";
}
<div class="container mt-5">
<h1>Student Details</h1>
<dl class="row">
<dt class="col-sm-2">ID</dt>
<dd class="col-sm-10">@Model.Id</dd>
<dt class="col-sm-2">Name</dt>
<dd class="col-sm-10">@Model.Name</dd>
<dt class="col-sm-2">Email</dt>
<dd class="col-sm-10">@Model.EmailId</dd>
<dt class="col-sm-2">Gender</dt>
<dd class="col-sm-10">@Model.Gender</dd>
</dl>
<div>
<a asp-action="Index" class="btn
btn-primary">Back to List</a>
</div>
</div>