Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im using multiple themes in my page. When choosing from dropdown,selected theme should be applied to whole page. While choosing the item from dropdown,im getting error as 'The Theme property can only be set in or before Page_PreInit Event'. How to solve this...
Posted

Try this
C#
protected void Page_PreInit(object sender, EventArgs e)
{
    if (IsPostBack)
    {
        Page.Theme = DropDown1.SelectedValue;
    }
  else
    {
      Page.Theme  = //defaule theme name 
    }
}

Use this link for reference
http://msdn.microsoft.com/en-us/library/tx35bd89.aspx
 
Share this answer
 
Comments
Priyaaammu 23-Jul-12 8:22am    
i tried this...but only the page getting refreshed and theme not changed
Hi,
Page_PreInit get called only once in page lyfecycle. You cannot use that for IsPostBack. Instead of that try this and put the conditions:
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        Page.Theme = DropDown1.SelectedValue;
    }
  else
    {
      Page.Theme  = //other themes name
    }
}



--Amit
 
Share this answer
 

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