asp-controller ,asp-action,asp-route-id represents the controller name,action name and the route value in the generated href attribute of <a> like <ahref="/CustomerService/AddProcedureToAppointment/1" id="btnAddProcedure" class="btn btn-outline-primary"></a>
As mgebhard suggested , you should set the href attribute of <a> like below:
function onSelectedIndexChanged(value) {
var textValue = value.options[value.selectedIndex].value; var newhref=$("#btnAddProcedure").attr('href') + '/' + textValue ;
$("#btnAddProcedure").attr("href", newhref);
}
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
2 Points
2 Posts
Value from asp-route-id dynamically
May 19, 2020 08:10 PM|viIsrael|LINK
Hey guys,
How can I select an item on <select> object and send it's value to an asp-route-id?
I have this code:
My controller:
But when I click in <a> I only get zero (initial value of @ProcedureID) not the value on <select>. What I'm doing wrong? How can I do this?
How can I do this?
All-Star
53751 Points
24068 Posts
Re: Value from asp-route-id dynamically
May 19, 2020 08:47 PM|mgebhard|LINK
Write click handler and read the select value.
Contributor
2070 Points
606 Posts
Re: Value from asp-route-id dynamically
May 20, 2020 02:27 AM|Sherry Chen|LINK
Hi viIsrael ,
asp-controller ,asp-action,asp-route-id represents the controller name,action name and the route value in the generated href attribute of <a> like <a href="/CustomerService/AddProcedureToAppointment/1" id="btnAddProcedure" class="btn btn-outline-primary"></a>
As mgebhard suggested , you should set the href attribute of <a> like below:
Reference: Anchor Tag Helper attributes
Best Regards,
Sherry
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
2 Points
2 Posts
Re: Value from asp-route-id dynamically
May 20, 2020 02:13 PM|viIsrael|LINK
Hi!
The two ways worked! Thanks!