Notes from the following Udemy course
What are tag helpers
Example
<input aspfor="ModelProperty">
<input type="text" name="ModelProperty" id="ModelProperty" value="ModelValue">
Predefined Tag helpers for <a> <form>
Predefined Tag helpers for <input> <textarea>, <label>
Predefined Tag helpers for <select>
How to import
@addTaghelper * {DLL_NAME}
@addTagHelper *, Microsoft.AspNetCore.MVC.TagHelpers
This is a regular anchor tag
<a href="~/persons/index" class="link-hover">Back to persons index page</a>
This is an anchor tag with the tag helpers asp-controller and asp-action
<a asp-controller="Persons" asp-action="Index" class="link-hover">Back to index page</a>
<input asp-for="ModelProperty />"
is equivalient to …
<input type="text" name="ModelProperty" id="ModelProperty" value="ModelValue" data-val-rule="ErrorMessage" />
public class PersonAddRequest{
// HERE WE ARE ADDING THE DATATYPE THAT WILL BE USED IN THE RENDERING OF THE VIEW
[DataType(DataType.Text)]
public string? PersonName { get; set; }
// HERE WE ARE ADDING THE DATATYPE THAT WILL BE USED IN THE RENDERING OF THE VIEW
[DataType(DataType.EmailAddress)]
[Required(ErrorMessage = "Email can't be blank")]
public string? Email { get; set; }
public Person ToPerson() {
// ...
}
}