how to change theme of a custom page programatically

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
1/7/2012 4:10:12 AM
Gravatar
Total Posts 192

how to change theme of a custom page programatically

hi joe.
I'd been trying to change the theme of a custom page.
but had no luck by now.
tried copying a code snippet from
mojobasepage (from setuptheme, to be exact)
and put the code in preinit of the page.
page code now starts with:

public partial class ProfilePage : mojoBasePage
{
override protected void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
//the following code comes from SetupTheme of mojoBasePage
this.Theme = "default" + siteSettings.SiteId.ToInvariantString() + "artisteer31-redpaint";
}

but the page's skin is still the site default, not "artisteer31-redpaint".

help please, thank you very much.

1/7/2012 11:38:48 PM
Gravatar
Total Posts 192

Re: how to change theme of a custom page programatically

hi again.

I achieved what I wanted by using the following code:

 

override protected void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
//((mojoBasePage)Page).AllowSkinOverride = true;        this is not needed.
((mojoBasePage)Page).MasterPageFile = SiteUtils.GetMasterPage(this, "artisteer31-redpaint", siteSettings, true);
CurrentPage.Skin = "artisteer31-redpaint";
((mojoBasePage)Page).StyleCombiner.AllowPageOverride = true;
}

 

any comments on it? any possible change in the future that may make it not work? or any robuster solution?

thanks.

You must sign in to post in the forums. This thread is closed to new posts.