More in this section
Forums / Developing with Sitefinity / Change Template at runtime

Change Template at runtime

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
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