Reputation: 963
I have some html that is used a lot in the site i'm building. So I created a App_Code\Helpers.cshtml file and placed the helperfunction in that file.
Now, I want to render a partial-view (a MVC view for a form). But I can't use @Html.Partial("MyFormPartial", new formModel())
I can't find any other ways of rendering a partial view from within a helper class. Anybody got an idea on how to solve this?
Is a seperate helpers.cshtml
even the best way for this kind of repeating html-code? I think it gives me a bit more freedom in the parameters I'm providing, instead of the macro's. But it sucks I can't use @Umbraco
(without creating your own helper) or @Html
:(
Upvotes: 0
Views: 148
Reputation: 6017
Just pass @Html
to the helper function if you don't want to create it inside the helper function.
Nevertheless, isn't it a better idea to use a child action and render part of code you'd like to been shared?
Upvotes: 1