ASP.NET MVC 2
I'm trying to write a view whose generic parameter is dynamic
, and then pass this dynamic model to a partial view
<%@ Page Title="" ..... Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
and then
<% Html.RenderPartial("MenuTabsPartial", Model); %>
but I'm getting the error
'System.Web.Mvc.HtmlHelper' has no applicable method named 'RenderPartial' but appears to have an extension method by that name ...
I am fully aware that extension methods cannot be dispatched with dynamic parameters.
My question is, is there some sort of MVC-specific work around?
This extension method has to be defined in a public static calss somewhere, right? Is it possible to invoke RenderPartial from there, like you can with linq:
Enumerable.Where(stringArray, s => s.StartsWith("Adam"));
You can find RenderPartial
in RenderPartialExtensions and RenderAction
in ChildActionExtensions.
So to call these methods with a dynamic parameter, you'd do:
<% RenderPartialExtensions.RenderPartial(Html, "MenuTabsPartial", Model); %>
and
<% ChildActionExtensions.RenderAction(Html, "List", Model); %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With