14 Aug 2012
19 Nov 2008
Link to this post
I need to change the master page (set page template in SiteFinity terms) of a custom page at runtime, based on a case scenario.
To be more specific, I have a created a page base class MyPage that inherits from InternalPage.
Now, let's say we have two templates in Sitefinity, default and someOtherMaster.
By design, pageA.aspx has the default template applied to it.
Depending on a logical test, I need to change the master page of pageA.aspx at runtime, but I don't want to save the chnage in the database.
What I did, is override the PreInit function of MyPage like this:
protected override void OnPreInit(EventArgs e)
Telerik.Cms.CmsManager manager = new Telerik.Cms.CmsManager();
IPageTemplate template = manager.GetTemplate("someOtherMaster");
That doesn't work as SetTemplate has to be used when editing/saving the page.
Is this case scenario possible?
If so, how do I overcome this problem?