Cannot implicitly convert void type to object..NET MVC PartialViewResult

I have the following controller action:

[ChildActionOnly] public virtual PartialViewResult ListActions(int id) { var actions = meetingActionRepository.GetAllMeetingActions(id); return PartialView(actions); } 

And the following action link (using t4MVC and razor syntax)

 <p> @Html.RenderAction(MVC.MeetingActions.ListActions(Model.MeetingId)) </p> 

However, this gives me an error:

cannot implicitly convert void type to object

As far as I can tell, the action of the controller is fine, so that can give me this error?

+64
c # asp.net-mvc asp.net-mvc-3 t4mvc
Feb 07 '11 at 10:50
source share
4 answers

Like this:

 <p> @Html.Action(MVC.MeetingActions.ListActions(Model.MeetingId)) </p> 

or if you insist on RenderAction as follows:

 <p> @{Html.RenderAction(MVC.MeetingActions.ListActions(Model.MeetingId));} </p> 

Personally, I prefer the first one, doing less keystrokes.

+102
Feb 07 '11 at 10:50
source share
— -

Html.Partial should work as well :)

 @Html.Partial("View", Model); 
+21
Nov 20 '13 at 18:03
source share

I had the same problem. For me it was to encapsulate an expression in curly braces .

@{Html.RenderPartial("viewName", Model);}

+9
Dec 08 '16 at 14:13
source share

Difference between Html.RenderAction and Html.Action

Different things for different purposes. Check out the link above.

+3
Mar 04 '12 at 7:10
source share



All Articles