+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Change Template at runtime

Change Template at runtime

2 posts, 0 answered
  1. Brandon
    Brandon avatar
    2 posts
    Registered:
    29 Jun 2012
    29 Jun 2012
    Link to this post
    I am trying to change the page template at runtime unsuccessfully. I'm getting runtime error of:
    "NolnetException: You cannot change the control fields after the object has been created in the cache."

    Telerik.Cms.Web.CmsSiteMapNode currentNode = (Telerik.Cms.Web.CmsSiteMapNode)SiteMap.CurrentNode;
    IPage page = cmsManager.GetPage(currentNode.GetCmsPage().ID,true);
    CmsTemplateContent pageTemplate = (CmsTemplateContent)cmsManager.GetTemplate(missingPageItem.Attributes["template"].Value);
    page.Template = pageTemplate.PageTemplate; // Exception thrown here

    Is there a way to do this?
  2. Brandon
    Brandon avatar
    2 posts
    Registered:
    29 Jun 2012
    02 Jul 2012
    Link to this post
    bump
2 posts, 0 answered