29.05.2015 Views

o_19mgorv9t13a3ko71fev19l81mqa.pdf

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 7-18. Creating a partial view<br />

Click the Add button, and Visual Studio will create a partial view file called<br />

Views/Shared/ProductSummary.cshtml. A partial view is similar to a regular view, except that it produces a<br />

fragment of HTML, rather than a full HTML document. If you open the ProductSummary view, you will see that it<br />

contains only the model view directive, which is set to the Product domain model class. Apply the changes shown in Listing<br />

7-28.<br />

Listing 7-28. Adding Markup to the ProductSummary.cshtml File<br />

@model SportsStore.Domain.Entities.Product<br />

<br />

<br />

@Model.Name<br />

@Model.Price.ToString("c")<br />

<br />

@Model.Description<br />

<br />

Now I need to update Views/Products/List.cshtml so that it uses the partial view. You can see the change in<br />

Listing 7-29.<br />

198

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

Saved successfully!

Ooh no, something went wrong!