Using RenderAction(actionname, values) in MVC4 issue

后端 未结 2 1677
醉酒成梦
醉酒成梦 2020-12-30 23:43

I need to display some child objects (Items) of an entity Request. Instead of Request I found it better to pass in a view that contains more info t

2条回答
  •  孤城傲影
    2020-12-31 00:31

    You need to use this syntax when calling the Render methods:

    @{ Html.RenderAction("Items", new { requestId = Model.Id }); }
    

    The @syntax, without the curly braces, expects a return type which gets rendered to the page. In order to call a method that returns void from the page, you must wrap the call in curly braces.

    Please see the following link for a more in-depth explanation.

    http://haacked.com/archive/2009/11/18/aspnetmvc2-render-action.aspx

提交回复
热议问题