RenderAction differences
Asked Answered
P

1

7

Why is this code correct:

 @{
   Html.RenderAction("PostImagesForPost", "BlogPost", new { id = Model.ID });
  }

And this code

 @Html.RenderAction("PostImagesForPost", "BlogPost", new { id = Model.ID })

through this error message:

Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments

Why it is so important to use the '{' '}'?

Thanks

Parget answered 19/3, 2014 at 14:59 Comment(0)
V
4

Html.RenderAction has to be called within a script block and can't be called in mark-up.

As an alternative in markup you would use:

@Html.Action("PostImagesForPost", "BlogPost", new { id = Model.ID })

For the differences on Action and RenderAction see here:

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

Venita answered 19/3, 2014 at 15:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.