3

I'm working through a MVC book which uses the older version of Html.RenderAction. So it looks like this in the book Html.RenderAction("Summary", "Cart"); I have had to convert to Html.RenderAction<CartController>(m => m.Summary(new Cart()));.

Where Summary looks like:

public ViewResult Summary(Cart cart)
{
    return View(cart);
}

I have a binding set up for Cart in the global.asax

ModelBinders.Binders.Add(typeof(Cart), new CartModelBinder());

So what is the best way do get the Binding to create the parameter cart instance rather then me manually doing it?

I have several ideas of how to fix this, but since I'm new to MVC I'm looking to see what the accepted practice is.

Thanks

g.foley
  • 2,152
  • 3
  • 19
  • 27

1 Answers1

0

Instead of using

HTML.RenderAction()

use

HTML.RenderPartial()

for eg:-

<% Html.RenderPartial("Summary", new cart(parameters)); %>

this will work sure.

biju
  • 17,554
  • 10
  • 59
  • 95
Febin J S
  • 1,358
  • 3
  • 26
  • 53
  • you can refer here for futher reference http://www.arrangeactassert.com/when-to-use-html-renderpartial-and-html-renderaction-in-asp-net-mvc-razor-views/ – Febin J S May 02 '11 at 06:54