user603007 user603007 - 7 months ago 19
Javascript Question

Asp.net MVC 3 error when calling Html.RenderAction

I am a newbie to asp.net mvc 3. How can you render a view within a div by calling an action:

html:

<div id="dialog-modal" title="Basic modal dialog">
@Html.RenderAction("Popup","Home");
</div>


c#:

public ActionResult Popup()
{
return PartialView();
}


I am getting an error:

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

Answer

Try wrapping your HtmlHelper in a code block:

@{ Html.RenderAction("Popup", "Home"); }