simple code to change theme on run time
Here is the most simple code to change the themes dynamically.
Here I am assuming that you have three themes named Red, Green and Blue, and you have three buttons named RedBtn, GreenBtn and BlueBtn to change theme on run time. I set Green as my initial theme.
protected void Page_PreInit(object sender, EventArgs e)
{
if((string)Session["Flag"]=="true")
Page.Theme =(string) Session["themeSelected"];
}
protected void RedBtn_Click(object sender, EventArgs e)
{
Session["Flag"] = "true";
Session["themeSelected"] = "Red";
Server.Transfer(Request.FilePath);
}
protected void GreenBtn_Click(object sender, EventArgs e)
{
Session["themeSelected"] = "Green";
Server.Transfer(Request.FilePath);
}
protected void BlueBtn_Click(object sender, EventArgs e)
{
Session["Flag"] = "true";
Session["themeSelected"] = "Blue";
Server.Transfer(Request.FilePath);
}
