

Note that TagHelper at the end of the class name is just a convention. We’ll create a new ColorLabelTagHelper class and let’s inherit from TagHelper class which is in namespace. The above custom tag should output the label in red color. So, the user can supply the color by providing color as an attribute to the colorlabel. In this article, we’ll create a label with color by default. Process Async(Tag Helper Context, Tag Helper Output) Asynchronously executes the TagHelper with the given context and output.įor the purpose of this post, we’ll override the Process method to synchronously execute the tag helper with the context and output our HTML. Process(Tag Helper Context, Tag Helper Output) Synchronously executes the TagHelper with the given context and output. Additions to Items should be done within this method to ensure they’re added prior to executing the children. Tag Helper class: public abstract class TagHelper : .ITagHelper Methods of Tag helper class: Method name Summary Init(Tag Helper Context) Initializes the ITagHelper with the given context. The Tag helper class has two methods that can be overridden. In this post, we’ll see how to create a custom tag helper in ASP.NET Core project.Ĭustom tag helpers can be created by implementing TagHelper class.
