I have a listing page with staff details with edit and delete link like this.
Now when i click on the Edit link,it should take me to the respective staff's details(The page will be like this,Implemented using Razor Pages Models)
This is my listingpage code,where in the edit link i will be passing the StaffID
Filename : StaffDirectory.cshtml
@page
@model Contractor_HRMS.Pages.Staff.Directory.StaffDirectoryModel
@{
ViewData["Title"] = "Staff Directory";
Layout = "~/Pages/Shared/_Layout.cshtml";
}
<h4>STAFF DIRECTORY</h4>
<hr />
<form asp-page="Staff/Directory/StaffDirectory" method="get">
<div class="row">
<div class="col-4">
<label class="control-label">Employee Name</label>
<input asp-for="SearchString" class="form-control-staff" type="text" />
</div>
<div class="col-4">
<label class="control-label">Location</label>
<select asp-for="Location" asp-items="Model.Location" class="form-control-staff">
<option value="">Please Select</option>
</select><br />
</div>
<div class="col-4">
<input type="submit" class="btn-success" value="SEARCH" />
</div>
</div>
</form>
<br />
<br />
<table class="table" border="1">
<thead style="background-color:silver;">
<tr>
<th>
Employee Name
</th>
<th>
Employee Type
</th>
<th>
Job Title
</th>
<th>
Location
</th>
<th>
Supervisor/Manager Name
</th>
<th>
Actions
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.StaffDetails)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.PreferredEmpFname) @Html.DisplayFor(modelItem => item.PreferredEmpLname)
</td>
<td>
@Html.DisplayFor(modelItem => item.EmploymentType)
</td>
<td>
@Html.DisplayFor(modelItem => item.JobTitle)
</td>
<td>
@Html.DisplayFor(modelItem => item.Location)
</td>
<td>
@Html.DisplayFor(modelItem => item.SupervisorName)
</td>
<td>
<img src="~/images/pencil(1).png" alt="Edit"> <a asp-page="./Details" asp-route-id="@item.StaffID">Edit</a> |
@*<a asp-page="./Details" asp-route-id="@item.ID">Details</a> |*@
<img src="~/images/icons8-delete-trash-16.png" alt="Delete"> <a asp-page="./Delete">Delete</a>
</td>
</tr>
}
</tbody>
</table>
<paging page-no="Model.P"
page-size="Model.S"
total-records="Model.TotalRecords"
query-string-value="@(Request.QueryString.Value)">
</paging>
Details Page with multiple Tabs,where navigation to each tab is handled by AJAX. File Name Details.cshtml
@page
@model Contractor_HRMS.Pages.Staff.Directory.DetailsModel
@{
ViewData["Title"] = "Staff Details";
Layout = "~/Pages/Shared/_Layout.cshtml";
}
<h4>STAFF DETAILS</h4>
<hr />
<div>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" role="tab" aria-controls="StaffDetails"
href="#StaffDetails">Staff Details</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" role="tab" aria-controls="Biodata"
href="#Biodata">Biodata</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" role="tab" aria-controls="EduQualification"
href="#EduQualification">Educational Qualification</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" role="tab" aria-controls="Assets"
href="#Assets">Assets</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" role="tab" aria-controls="AttachForms"
href="#AttachForms">Attachment Of Forms</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" role="tab" aria-controls="Training"
href="#Training">Training</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" role="tab" aria-controls="Awards"
href="#Awards">Awards</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" role="tab" aria-controls="DisciplinaryAction"
href="#DisciplinaryAction">Disciplinary Action</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" role="tab" aria-controls="StaffOffBoarding"
href="#StaffOffBoarding">Staff OffBoarding</a>
</li>
</ul>
</div>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="StaffDetails" role="tabpanel" aria-labelledby="StaffDetails-tab">
</div>
<div class="tab-pane fade" id="Biodata" role="tabpanel" aria-labelledby="Biodata-tab">
</div>
<div class="tab-pane fade" id="EduQualification" role="tabpanel" aria-labelledby="EduQualification-tab">
</div>
<div class="tab-pane fade" id="Assets" role="tabpanel" aria-labelledby="Assets-tab">
</div>
<div class="tab-pane fade" id="AttachForms" role="tabpanel" aria-labelledby="AttachForms-tab">
</div>
<div class="tab-pane fade" id="Training" role="tabpanel" aria-labelledby="Training-tab">
</div>
<div class="tab-pane fade" id="Awards" role="tabpanel" aria-labelledby="Awards-tab">
</div>
<div class="tab-pane fade" id="DisciplinaryAction" role="tabpanel" aria-labelledby="DisciplinaryAction-tab">
</div>
<div class="tab-pane fade" id="StaffOffBoarding" role="tabpanel" aria-labelledby="StaffOffBoarding-tab">
</div>
</div>
@section scripts
{
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
<script src="~/lib/jquery-ajax-unobtrusive/dist/jquery.unobtrusive-ajax.js"></script>
<script>
$(function () {
$.ajax({
url: "/Staff/Directory/StaffDetails",
type: "get",
success: function (result) {
$("#StaffDetails").html(result);
}
})
$.ajax({
url: "/Staff/Directory/Biodata",
type: "get",
success: function (result) {
$("#Biodata").html(result);
}
})
$.ajax({
url: "/Staff/Directory/EduQualification",
type: "get",
success: function (result) {
$("#EduQualification").html(result);
}
})
$.ajax({
url: "/Staff/Directory/Assets",
type: "get",
success: function (result) {
$("#Assets").html(result);
}
})
})
function firstCompleted(event) {
if (event.responseText != "") {
$("#StaffDetails").html(event.responseText);
} else {
$('a[href="#Biodata"]').tab('show');
}
}
//function secondCompleted() {
// $('a[href="#EduQualification"]').tab('show');
//}
//function thirdCompleted() {
// $('a[href="#Assets"]').tab('show');
//}
//function forthCompleted() {
// alert("All Submit")
//}
</script>
}
Now my Details Page url will be like this https://localhost:44345/Staff/Directory/Details?id=5
How can i prepopulate the details in all the forms? How can i pass the StaffID through AJAX url? Is it possible to pass both StaffID and EmpID through asp-page-route attribute?



