部分视图与模型

模型也可以添加到局部视图中:

@model Solution.Project.Namespace.MyModelClass
<p>@Model.Property</p>

在视图中,你现在可以使用:

<div>
    @Html.Partial("PartialViewExample", new MyModelClass(){Property="my property value"})  
</div>
<div>
    @{ Html.RenderPartial("PartialViewExample", new MyModelClass(){Property="my property value"}); }  
</div>