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

Challenge: Use a child action to make a smarter HTML helper

From the course: ASP.NET MVC: Building for Productivity and Maintainability

Start my 1-month free trial

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…

Contents