

In the AsyncEmailTester.cshtml page: Black.Widow For the Email and AsyncEmail Tag Helpers, the corresponding tags in your Razor Page would be and respectively. In order to use the tag helper in a Razor Page, simply add a using statement for the Tag Helper’s namespace, and then include a custom HTML tag that has the same name as the Tag Helper’s class name (without the TagHelper suffix).

Public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) ASYNC method, REQUIRED to call output.GetChildContentAsync() It contains a ProcessAsync() method, which has a different signature (returns Task object instead of void) and grabs the child content from the output using output.GetChildContentAsync() public class AsyncEmailTagHelper : TagHelper The class AsyncEmailTagHelper.cs defines a tag helper that is also a subclass of the TagHelper class, saved in the aforementioned “TagHelpers” folder. Public override void Process(TagHelperContext context, TagHelperOutput output) synchronous method, CANNOT call output.GetChildContentAsync() It contains a Process() method that changes the output of the HTML tag it is generating. The class EmailTagHelper.cs defines a tag helper that is a subclass of the TagHelper class, saved in the “TagHelpers” folder. While the official tutorial was originally written to cover instructions for MVC views, this blog post takes a look at a Razor Page example. The creation of Tag Helpers involves the same process in either case. Let’s start with the synchronous and asynchronous versions of a Tag Helper that formats email addresses.
INPUT AND GETOUTPUT FOR A TEXTBAR ON JS CODE
This blog post and its corresponding code sample builds upon the official tutorial for authoring tag helpers.

You can save your custom tag helper classes in this folder. In the case of Tag Helpers, you should start with a “TagHelpers” folder at the root-level of your project for your convenience. NET Core, it helps to use named folders and conventions to ease the development process. To make things easier, the TagHelper class (which already implements the aforementioned interface) can be extended to build your custom tag helpers.Īs with most concepts introduced in ASP. NET Core, you may revisit an earlier post in this series:Īuthoring your own tag helpers is as easy as implementing the ITagHelper interface. If you need a refresher on built-in tag helpers in ASP. They work equally well in both Razor Pages and MVC views. Better yet, the syntax allows a front-end developer to easily customize the UI, with HTML/CSS knowledge. NET Core developers in creating HTML elements with server-side attributes.

NOTE: The NetLearner suite of apps doesn’t currently use custom tag helpers in the main branch, so you can check out the new sample code in the experimental subfolder, merged from a branch:
INPUT AND GETOUTPUT FOR A TEXTBAR ON JS SERIES
NET Core A-Z! To differentiate from the 2019 series, the 2020 series will mostly focus on a growing single codebase ( NetLearner!) instead of new unrelated code snippets week. In this series, we’ll cover 26 topics over a span of 26 weeks from January through June 2020, titled ASP. This is the twentieth of a new series of posts on ASP.
