Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC RenderAction re-renders whole page

How do I prevent renderaction from rendering the masterpage and giving it back to me? I only want it to render 1 section, for eg.

The controller

public ActionResult PaymentOptions()
{
    return View(settingService.GetPaymentBanks().ToList());
}

The PaymentOptions View:

@model IEnumerable<Econo.Domain.PaymentBank>

<h2>Payments</h2>
<!-- Stuff here -->

The View

<div class="grid_10">

</div>

<div class="grid_14">
@{Html.RenderAction("PaymentOptions", "Administrator");}
</div>

In grid_14, the header, footer and everything else gets rendered. Is there a way to prevent this?

like image 570
Shawn Mclean Avatar asked May 27 '11 17:05

Shawn Mclean


1 Answers

public ActionResult PaymentOptions()
{    
    return PartialView(settingService.GetPaymentBanks().ToList());
}

In Razor, partial views and full views have the same extension, so you need to explicitly use the PartialViewResult result type to specify a partial view.

like image 194
AaronShockley Avatar answered Nov 08 '22 10:11

AaronShockley