From the course: ASP.NET MVC: Building for Productivity and Maintainability
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: Use a child action to make a smarter HTML helper
From the course: ASP.NET MVC: Building for Productivity and Maintainability
Challenge: Use a child action to make a smarter HTML helper
- [Instructor] In this chapter, I showed you how to create custom HTML helpers and child actions to simplify your views and ensure that all of your application logic is where it needs to be in your controllers. But, do you remember when I refactored this view? To move all the product rating logic into the custom rating HTML helper? Well, that was a great step in the right direction but it still really bugs me that the product action has to retrieve the rating object and put it in the view data dictionary just so the view can retrieve it to pass to the HTML helper. In other words, I wish I had a version of the rating HTML helper that accepts just the product SKU like this. And then, that helper can figure out what needs to happen from there. Your challenge is to use a combination of an HTML helper and a child action to make this updated call work. Much like most of the examples in this course, you'll know that you've succeeded once you see the same exact markup being rendered. But, the…
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
-
-
-
-
-
Using extension methods to remove magic strings5m 30s
-
(Locked)
Using extension methods to strongly type common actions4m 38s
-
(Locked)
Creating custom HTML helpers to reduce and reuse markup6m 16s
-
(Locked)
Using child actions to generate complex common markup4m 59s
-
(Locked)
Challenge: Use a child action to make a smarter HTML helper1m 29s
-
(Locked)
Solution: Use a child action to make a smarter HTML helper4m 16s
-
-
-
-
-
-