top of page

ASP Tag Helpers

ASP Tag Helpers enable server-side code to participate in creating and rendering HTML elements in Razor files.

So, what does that mean?

Great question, I'll give an example on how I used one, in this case asp-action.

In the yellow highlighted code example to your right, the form asp-action Tag Helper says I'm looking for ActionResult named Team in my controller on the Post event.

Other Form Action tag helpers are:

  1. asp-controller

  2. asp-action

  3. asp-area

  4. asp-page

  5. asp-page-handler

  6. asp-route

  7. asp-route-{value}

  8. asp-all-route-data

  9. asp-fragment

<div class="col-sm-4">
       
<form asp-action="Team" method="post">
            @using (Html.BeginForm("Team", "Players", FormMethod.Post, new { id = "Form1" }))
            {
            <div>
                Find by name: <input type="text" name="SearchString" value="@ViewData["CurrentFilter"]" />
                <input type="submit" value="Search" class="btn btn-default" /> |
                <a asp-action="Index">Back to Full List</a>
            </div>
            }
        </form>
    </div>

bottom of page