nugget
nugget

Reputation: 155

Umbraco render strongly typed partial from api

What i'm trying to do:

I've found helpful answers like:

http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/render-razor-scripts-for-emails-and-more/create-string-of-partial-view-for-emailing

http://our.umbraco.org/forum/developers/api-questions/44916-615-Returning-Partial-View-as-string-to-JSON

But I can't figure out what Controller or ControllerContext to pass in since I'm not in a Razor view or RenderMvcController.

Some help please?

Upvotes: 1

Views: 1138

Answers (1)

Sébastien Richer
Sébastien Richer

Reputation: 1691

I normally call (with js, ajax, jquery) an Umbraco Surface controller and I pass my current page's node id. Then on server, I do:

var currentPage = Umbraco.TypedContent(myNodeIdParam);

From there I usually have enough context and I can return a partial view, passing it a model I want.

Hope this helps!

Upvotes: 2

Related Questions