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.

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

Solution: 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

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

(upbeat music) - [Instructor] For this challenge, I left you hanging with a call to an HTML helper that didn't exist. And I asked you to help clean up the product controller action that powers this view and reduce the dependency on passing information around in the view data dictionary. In order to solve this challenge, you had to do two things. You had to create a new child action which accepted a product SKU and retrieved the rating information from the database. Then rendered the rating markup using the existing rating HTML helper. And you had to create an overload to that existing HTML helper to call this new child action and render its result. Now it really didn't matter which order you completed these steps since you need both of them in order to have the full solution. However I'll start by creating the new child action and I'll do it by creating a new action in the product's controller named rating which accepts a product sku as its parameter. And of course don't forget the…

Contents