From the course: Learning ASP.NET Core MVC
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Use tag helpers to simplify forms
From the course: Learning ASP.NET Core MVC
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
Create strongly typed HTML forms4m 5s
-
(Locked)
Post form data to controller actions4m 9s
-
(Locked)
Validate form post data5m 55s
-
(Locked)
Use tag helpers to simplify forms5m 7s
-
(Locked)
Represent the database using Entity Framework6m 9s
-
(Locked)
Write to a database using Entity Framework1m 35s
-
(Locked)
Read from a database using Entity Framework2m 26s
-
-
-
-