문제

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

도움이 되었습니까?

해결책

Instead of using

HTML.RenderAction()

use

HTML.RenderPartial()

for eg:-

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

this will work sure.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top