A select populated using razor
- <select placeholder="Select campus" id="selCampus" class="form-control" required>
- <option value="">Select campusoption>
- @foreach (var campus in Model.Campuses)
- {
- <option value="@campus.Id">@campus.CampusNameoption>
- }
- select>
Onchange for the select pointing to the action controller
- $("#selCampus").change(function () {
- //$(".employee").remove();
- $.ajax({
- type: 'POST',
- url: '/admin/staff/',
- dataType: 'html',
- data: ({
- campusId: $(this).val()
- }),
- success: function () {
- }
- });
- });
- public ActionResult Employees(long? campusId)
- {
- var client = new RestClient(Request.Url.GetLeftPart(UriPartial.Authority).ToString());
- var request = new RestRequest("api/employee/getClinicMembers/{campusId}", Method.POST);
- request.AddParameter("campusId", campusId, ParameterType.QueryString);
- var result = client.Execute
(request); - ViewBag.title = "Home | Members";
- return View(result.Data);
- }
- @foreach (var member in Model.Employees)
- {
- <div class="col-lg-4 col-xlg-3 col-md-5 employee">
- <div class="card">
- <div class="card-body">
- div>
- div>
- div>
- }
Anele NgqanduPosted Apr 25, 2019, 7:47 AM
Jenith ThakkarPosted Apr 23, 2019, 4:13 AM