From the course: Learning ASP.NET Core MVC
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Reuse view logic with injectable services
From the course: Learning ASP.NET Core MVC
Reuse view logic with injectable services
- [Instructor] By this point in the course, I've shown you several different HTML helper methods and you've accessed these helpers from the special HTML and URL properties in the view and trust me, the more you use asp.net Core MVC, the more you're going to want to create your own helpers and custom properties and in this video, that's exactly what I'm going to show you how to do. For a good example of the need for a custom helper method, take a look at how we're rendering the posted date property. When we leave it up to razor to render it, it ends up displaying some long string with a time including seconds and everything. But what if we only wanted to display the date? We could change the code in this one place to make that happen and that's all well and good, but what if we applied this approach all over our application and then we wanted to change the way that we displayed all of our dates, wherever they're rendered? Well, then we'd have to search for all those references and…
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
-
-
-
-
-
-
-
(Locked)
Reuse view markup with partial views4m 13s
-
(Locked)
Reuse view logic with injectable services3m 16s
-
(Locked)
Creating reusable components with view components4m 51s
-
(Locked)
Enhancing a view component with logic and dynamic markup4m 15s
-
(Locked)
Avoid page refreshes with partial rendering5m 8s
-
(Locked)
-
-