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
1

2 Answers 2

3

Try wrapping your HtmlHelper in a code block:

@{ Html.RenderAction("Popup", "Home"); }
Sign up to request clarification or add additional context in comments.

1 Comment

I prefer doing @Html.Action(); instead of this, as documentation at stackoverflow.com/questions/6980823/…
-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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.