TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anele Ngqandu
1.3k
429
27.8k
How to fix my search using a select that is populated razor
Apr 22 2019 12:44 PM
A select populated using razor
<
select
placeholder
=
"Select campus"
id
=
"selCampus"
class
=
"form-control"
required
>
<
option
value
=
""
>
Select campus
</
option
>
@foreach (var campus in Model.Campuses)
{
<
option
value
=
"@campus.Id"
>
@campus.CampusName
</
option
>
}
</
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
() {
}
});
});
ActionResult, this loads on pageload and onchange of the select
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);
}
Does not want to redraw this code with new data, Even tho Model.Employees has filtered 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
>
}
Reply
Answers (
2
)
Regarding multiple array passing to single method.
Need OAuth authorization sample code