Sha*_*ean 6 asp.net-mvc asp.net-mvc-3
如何防止渲染渲染母版页并将其还给我?我只希望它渲染1个部分,例如.
控制器
public ActionResult PaymentOptions()
{
return View(settingService.GetPaymentBanks().ToList());
}
Run Code Online (Sandbox Code Playgroud)
PaymentOptions视图:
@model IEnumerable<Econo.Domain.PaymentBank>
<h2>Payments</h2>
<!-- Stuff here -->
Run Code Online (Sandbox Code Playgroud)
风景
<div class="grid_10">
</div>
<div class="grid_14">
@{Html.RenderAction("PaymentOptions", "Administrator");}
</div>
Run Code Online (Sandbox Code Playgroud)
在grid_14中,页眉,页脚和其他所有内容都会被渲染.有办法防止这种情况吗?
小智 11
public ActionResult PaymentOptions()
{
return PartialView(settingService.GetPaymentBanks().ToList());
}
Run Code Online (Sandbox Code Playgroud)
在Razor中,部分视图和完整视图具有相同的扩展名,因此您需要显式使用PartialViewResult结果类型来指定局部视图.
| 归档时间: |
|
| 查看次数: |
2094 次 |
| 最近记录: |