Search code examples
c#asp.netvisual-studiorazorumbraco

Calling Partial Views in Razor


I have a question that seems to be driving me mad. How can I pull a partial view from another master into my home page (which is not related to the view, etc.) and is in another folder? I just want to reference:

@Html.ThemedPartial(Model, "Latest")

(which is from the Articulate blog in Umbraco). However, I am not sure how to do this because I do not know what using directives to include, etc.?

Is there an easy way to do this?

I'm receiving the following error:

Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper>' does not contain a definition for 'ThemedPartial' and no extension method 'ThemedPartial' accepting a first argument of type 'System.Web.Mvc.HtmlHelper>' could be found (are you missing a using directive or an assembly reference?)

It is quoting the source error at @Html.ThemedPartial(Model, "Latest")

I also tried @Html.Partial("~/App_Plugins/Articulate/Themes/MyTheme/Views/Partials/Latest.cshtml", Model) instead of @Html.ThemedPartial(Model, "Latest") with no luck. I am getting the following:

Umbraco.Web.Mvc.ModelBindingException: Cannot bind source content type Umbraco.Web.PublishedContentModels.Index to model type Articulate.Models.IMasterModel.


Solution

  • I figured it out:

    @Html.Partial("~/Views/Partials/Recent.cshtml", Model)