0

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
Danny Mahoney
  • 1,255
  • 2
  • 13
  • 24
user603007
  • 11,416
  • 39
  • 104
  • 168
  • http://stackoverflow.com/questions/4964042/asp-net-mvc-how-to-pass-url-parameters-using-html-renderaction-to-a-childaction – hwiechers Aug 04 '12 at 08:04

2 Answers2

3

Try wrapping your HtmlHelper in a code block:

@{ Html.RenderAction("Popup", "Home"); }
Mark Oreta
  • 10,346
  • 1
  • 33
  • 36
  • I prefer doing `@Html.Action();` instead of this, as documentation at http://stackoverflow.com/questions/6980823/html-renderpartial-syntax-with-razor/6980974#6980974 – Tom Roggero Jan 15 '14 at 21:15
-2

From Wrox.Professional.ASP.NET.MVC.3.Aug.2011 page 115

Html.Action and Html.RenderAction Action and RenderAction are similar to the Partial and RenderPartial helpers. The Partial helper typically helps a view render a portion of a view’s model using view markup in a separate file. Action, on the other hand, executes a separate controller action and displays the results. Action offers more flexibility and re-use, because the controller action can build a different model and make use of a separate controller context. Once again, the only difference between Action and RenderAction is that RenderAction writes directly to the response (which can bring a slight efficiency gain).

Edi Wang
  • 3,547
  • 6
  • 33
  • 51