Click here to Skip to main content
15,917,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How To handle more then one theme in asp.net C#?

Like i have to do switch on old theme and new them
Posted

Themes can be applied in 3 ways

1. Folder Level
2. Application Level
3. Page Level.

if u want to switch the themes you can apply based on the condition.

To apply a page theme progmatically

C#
switch (Request.QueryString["theme"])
    {
        case "Blue":
            Page.Theme = "BlueTheme";
            break;
        case "Pink":
            Page.Theme = "PinkTheme";
            break;
    }
<b>To apply control skins programmatically</b>

ControlerID.SkinID = "CustomSkin";
 
Share this answer
 
v2
C#
public class Global : System.Web.HttpApplication
{

    protected void Application_PostMapRequestHandler(object sender, EventArgs e)
    {
        Page activePage = HttpContext.Current.Handler as Page;
        if (activePage == null)
        {
            return;
        }
        activePage.PreInit
            += (s, ea) =>
            {

                string selectedTheme = HttpContext.Current.Session["SelectedTheme"] as string;
                if (Request.Form["ctl00$ddlTema"] != null)
                {
                    HttpContext.Current.Session["SelectedTheme"]
                        = activePage.Theme = Request.Form["ctl00$ddlTema"];
                }
                else if (selectedTheme != null)
                {
                    activePage.Theme = selectedTheme;
                }

            };
    }
 
Share this answer
 
Comments
Gihan Liyanage 15-Sep-14 6:14am    
Did you got a solution from my support, I can see you have not accepted any answer.If you are ok with this answer plz accept it. Then any user having same problem can identified it has solved the problem..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900