Copied to clipboard

Flag this post as spam?

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


  • Jonathan Roberts 409 posts 1063 karma points
    Jun 27, 2017 @ 16:05
    Jonathan Roberts
    0

    GetGridHtml - Can I get html for a versioned page?

    Hi,

    I have a bit of code that I am playing around with and I wondered if it was possible to get the HTML markup of the page?

    The code is:

     IContentService cs = ApplicationContext.Current.Services.ContentService;
            IContent specificVersion = cs.GetByVersion(versionId);
    
            var currentPageId = 1079;
            var umbracoHelper = new UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
            IPublishedContent content = umbracoHelper.TypedContent(currentPageId);
    
            IPublishedContent currentPage = Extensions.ContentExtensions.ToPublishedContent(specificVersion, true);
            var tt = content.GetGridHtml("gridAlias", "gridRenderer");
    

    But the last line var tt - I have no idea if it is possible to GetGridHtml - it seems like I need to pass in HtmlHelper but I need help setting this up.

    Any ideas?

    The currentPage = Extensions snippet is from a previous ticket: https://our.umbraco.org/forum/using-umbraco-and-getting-started/86540-render-page-as-html-using-a-page-version-guid

    Jon

  • Frans de Jong 548 posts 1840 karma points MVP 3x c-trib
    Jun 28, 2017 @ 23:10
    Frans de Jong
    0

    I don't know how to do it for your specific case but to render grid you normaly need:

    @Html.GetGridHtml(IPublishedContent, "propertyAlias", "template")
    

    Where template is a partialview in the Views/Partials/Grid folder.

Please Sign in or register to post replies

Write your reply to:

Draft