2012-08-04 34 views
0

当我是一个新手,通过调用一个动作ASP.NET MVC 3,你怎么能呈现一个div内的视图:Asp.net MVC 3错误调用Html.RenderAction

HTML:

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

C#:

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

我得到一个错误:

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

http://stackoverflow.com/questions/4964042/asp-net-mvc-how-to-pass-url-parameters-using-html-renderaction-to-a-childaction – hwiechers 2012-08-04 08:04:37

回答

2

尝试在一个代码块包装的的HtmlHelper:

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

tatetewel bedankt – user603007 2012-08-04 08:23:55

+0

我更喜欢做'@ Html.Action();'而不是,作为文档在http://stackoverflow.com/questions/6980823/html-renderpartial-syntax-with-razor/6980974#6980974 – 2014-01-15 21:15:23

-2

从Wrox.Professional.ASP.NET.MVC.3.Aug.2011第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).