how to navigate between various views by clicking buttons

elsvieta 371 Reputation points
2023-11-27T18:20:18.7233333+00:00

hi all,

I am writing an mvc asp.net 8 core application.

I would need some clarification on how do I navigate from one page to another.

For starters: I have a page where I want to display a few buttons in the body of the page and I need to open a different page for each button. I have a folder for each "page" with its View, Controller and entry in BaseViewModel.

Thanks,

elsvieta

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET Other
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2023-11-27T21:32:29.55+00:00

    the easiest is to use an anchor tag helper:

    https://learn.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/anchor-tag-helper?view=aspnetcore-8.0

    sample:

    <a class="btn btn-primary" role="button" asp-controller="MyController" asp-action="MyAction">
       click me
    </a>
    
    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.