Tag Helpers

Tag Helpers are a new feature introduced in ASP.NET Core that enables server-side code to participate in creating and rendering HTML elements in Razor files. Tag Helpers are C# classes that participate in view generation by manipulating HTML elements. By using Tag Helpers, we can add additional attributes to HTML elements, change the content, or replace them entirely. In simple terms, Tag Helper's code that helps us to build our .cshtml forms without needing to write Razor syntax. For example, if we were to write an anchor tag in Razor we would write it like:

@Html.ActionLink("Read my book", "Read", "Book") 

where Read is the action in Book controller and the text between anchor tag would be "Read my book". Using Tag Helper, it ...

Get .NET Core 2.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.