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
From the course: ASP.NET MVC: Building for Productivity and Maintainability
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…
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
-
-
-
-
-
-