25 Using tag helpers

This chapter covers

  • Transforming HTML elements using tag helpers
  • Receiving context data in a tag helper class
  • Registering and applying tag helpers
  • Selecting elements to transform with tag helper scope
  • Creating custom shorthand elements
  • Generating content for view model properties
  • Creating tag helpers that can be consumed through dependency injection

Tag helpers are C# classes that transform HTML elements in a view or page. Common uses for tag helpers include generating URLs for forms using the application’s routing configuration, ensuring that elements of a specific type are styled consistently, and replacing custom shorthand elements with commonly used fragments of content. In this chapter, I describe how tag helpers work ...

Get Pro ASP.NET Core 7, Tenth Edition 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.