tags:

views:

688

answers:

1

I have written an Action method for an ASP.NET MVC controller, which is being used to provide a model to a usercontrol.

public class ProductsController : Controller {

    public PartialViewResult ProductSummary()
    {
        ViewData.Model = new ProductSummaryModel("42"); // dummy data for now

        return new PartialViewResult()
        {
            ViewData = ViewData
        };
    }
}

I am using the 'futures' Microsoft.Web.Mvc dll and rendering the control in my main view like this :

<% Html.RenderAction<ProductsController>(x => x.ProductSummary()); %>

What I have here appears to work just fine, but i attempted to google new PartialResult() to see if what I was doing was following the correct patterns.

Currently this search only comes up with 4 results!

So I figured I'm doing somethin wrong here in my controller. Whats the correct way to create an action method that returns a partial view? And what (if anything) is wrong or bad about what I'm doing.

+2  A: 

I usually just use:

return PartialView("MyView", myModel);

But this just returns a new PartialViewResult("MyView", myModel) so it is potatoes/potatoes.

veggerby
58 google matches for that one )
Simon_Weaver
what i had just looked bad. especially ViewData = ViewData. it felt wrong
Simon_Weaver