A partial element invokes a Razor partial view and supplies its view model. Use it to move repeated markup into one template while leaving the rendered response unchanged. In MVC views, place it directly in a loop or another view; in Razor Pages, the partial receives the selected model value rather than the page model. section 22.5.3 section 23.5.2 section 7.5.3
Configure the element with attributes that control lookup and model data:
- Use name to select the partial view; lookup follows the regular view-search process. section 22.5.3
- Use model to pass an explicit object, such as p in a product loop or Model.Product in a Razor Page. section 22.5.3 section 23.5.2
- Use for to select a model value through an expression, such as a Product object's Name property. section 22.5.3
Render product rows
A strongly typed List.cshtml view can iterate over products and invoke _RowPartial for each one: <partial name="_RowPartial" model="p" />. The row partial can then invoke _CellPartial with for="Name", passing the product's string property to a separately typed cell template. Requesting /home/list renders the resulting table.
Share a product summary
Define ProductSummary.cshtml in Views/Shared with @model Product, then invoke it from Index.cshtml using <partial name="ProductSummary" model="p" />. The same product-card markup can appear in any view that needs the summary.
