C#C
C#4y ago
7 replies
CoreVisional

❔ 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
<a asp-controller="Example" asp-action="Details" value="1">
  //
</a>

<a asp-controller="Example" asp-action="Details" value="2">
  //
</a>

Controller
[HttpGet]
public IActionResult Summary(int viewsIndicator) 
{
  return View(); 
}

I'm not sure how to do something like this in ASP
public IActionResult Summary(int viewsIndicator) 
{
  if (value === 1) {
    // filter out what to show
  } else {
    // further filtering
  }
}
Was this page helpful?