From the course: Learning ASP.NET Core MVC

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Use tag helpers to simplify forms

Use tag helpers to simplify forms

From the course: Learning ASP.NET Core MVC

Start my 1-month free trial

Use tag helpers to simplify forms

- [Instructor] The HTML helpers that I've shown in various places in this course are a great way to generate HTML in your views. However, in this video I'm going to show you how to gain more control over your HTML while still taking advantage of ASP.NET Core MVCs HTML generation capabilities with a feature called tag helpers. Using the tag helper approach, you write all of your HTML exactly the way you want it and then apply special attributes that Razor picks up at runtime and then dynamically modifies your HTML as it needs to. To demonstrate what tag helpers are and how to use them, I'll rewrite this form using the tag helper approach instead of the HTML helpers that I've been using. Tag helpers are not included in any views by default. So in order to use them, you must first add a reference to them using the addTagHelper Razor directive. The syntax for this directive is pretty straightforward. Just specify the full name of the tag helper type including the assembly that it lives in…

Contents