29.05.2015 Views

o_19mgorv9t13a3ko71fev19l81mqa.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Figure 7-17. The design-enhanced SportsStore application<br />

Creating a Partial View<br />

As a finishing trick for this chapter, I am going to refactor the application to simplify the List.cshtml view. I am going to<br />

create a partial view, which is a fragment of content that you can embed into another view, rather like a template. Partial views<br />

are contained within their own files and are reusable across multiple views, which can help reduce duplication if you need to<br />

render the same kind of data in several places in your application.<br />

To add the partial view, right-click the /Views/Shared folder in the SportsStore.WebUI project and select<br />

Add View from the pop-up menu. Set View Name to ProductSummary, set Template to Empty, select<br />

Product from the Model Class drop-down list and check the Create As A Partial View box, as shown<br />

in Figure 7-18.<br />

197

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!