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:
-
asp-controller
-
asp-action
-
asp-area
-
asp-page
-
asp-page-handler
-
asp-route
-
asp-route-{value}
-
asp-all-route-data
-
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>