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
Marius Vasile
590
1.9k
148.7k
asp.net core passing jquery val as asp-route-id parameter
Feb 24 2021 5:01 PM
I have the following jquery
$(function () {
$(
"#Asset"
).on(
"change"
, function () {
var categoryId = $(
this
).val();
$(
"#Equipment"
).empty();
$(
"#Equipment"
).append(
"<option value=''>--Select Equipment--</option>"
);
$.getJSON(`?handler=Equipment&id=${categoryId}`, (data) => {
$.each(data, function (i, item) {
$(
"#Equipment"
).append(`<option value=
"${item.value}"
> ${item.text}</option>`);
});
$(
'#Equipment'
).selectpicker({ liveSearch:
true
});
});
$.getJSON(`?handler=AssetDetails&id=${categoryId}`, (data) => {
if
(!jQuery.isEmptyObject(data)) {
$(
"#AssetID"
).val(data.assetID);
$(
"#AssetName"
).val(data.assetName);
$(
"#AssetManufacturer"
).val(data.assetManufacturer);
}
});
});
});
and a button
<button
class
=
"btn form-control"
type=
"submit"
asp-page-handler=
"Test"
asp-route-id=
"id"
id=
"testid"
>Button</button>
Select
<div
class
=
"col-md-5"
>
<select id=
"Asset"
class
=
"form-control"
asp-items=
"@(new SelectList(string.Empty, "
WOAId
", "
AssetID
", "
AssetName
", "
AssetManufacturer
"))"
data-style=
"border-warning bg-transparent"
>
<option value=
""
>--Select Asset--</option>
</select>
</div>
How do I pass $("#AssetID").val(data.assetID); as id in button asp-route-id?
Reply
Answers (
10
)
to enable CORS Policy
Is it necessary to use IdentityUser in asp.net core or asp.net mvc?