Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • keilo 568 posts 1023 karma points
    Dec 06, 2015 @ 16:09
    keilo
    0

    Calling RenderTemplate in Save Event Handler

    Need some guidance on how to call

    Umbraco.RenderTemplate(pageId).ToString();
    

    to get the full rendered HTML of the page

    inside a Event Handler like;

     ContentService.Published += ContentServicePublished;   
    ..
    private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs

    It gives:

    The type or namespace name 'RenderTemplate' does not exist in the namespace 'Umbraco'

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Dec 09, 2015 @ 07:50
    Marc Goodson
    1

    Hi Keilo

    Inside your event you do not have access to the UmbracoHelper methods via

    Umbraco.
    

    (UmbracoHelper methods contain RenderTemplate etc)

    You should be able to do the following, to construct an UmbracoHelper instance

      UmbracoHelper umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
    

    and then be able to write

    var fullHTML = umbracoHelper.RenderTemplate(pageId).ToString();
    

    if that helps ?

Please Sign in or register to post replies

Write your reply to:

Draft