❔ How to pass anchor tag values to controller to render view based on selected value
HI, how do I pass the values assigned to an anchor tag to the controller so that the controller can render the view or filter out what to show to the user? For example, I have in my views
Controller
I'm not sure how to do something like this in ASP
6 Replies
<a asp-controller="Example" asp-action="Summary" asp-route-viewsIndicator="1"></a>
should work, no?
https://learn.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/anchor-tag-helper?view=aspnetcore-6.0#asp-route-valueIs
asp-route-id
and asp-route-{value}
the same thing?
Seems like I can use either oneid
is the name of the parameter you want to set
you have to replace {value}
accordingly 😉Got it. Btw, since I'm using numbers as indication, is it possible have the url parameter to not show the numbers and instead show something else? Like if the user clicks on All locations, the parameter should be /Location/AllLocations, and not /Location/Summary?viewsIndicator=1
use an
enum
instead? i think that should work out-of-the-box 😉Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.