.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Articles >> ASP.NET >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Changing the page theme dynamically at run time

Posted By:Gowthammanju       Posted Date: July 29, 2011    Points: 200    Category: ASP.NET    URL: http://www.dotnetspark.com  

this article shows how to dynamically change the themes during run time

Here it is as

step 1:Drag and place the dopdown list in design page and assign the color  to its data item as


step 2:as changing is possible only in Page_PreInit event so call that event a below

protected void Page_PreInit(object sender, EventArgs e)
        string manju;
        manju= (string)Session["theme"];
        if (manju!= null)
            Page.Theme = manju;
            DropDownList1.Text = manju;
            Session["theme"] = DropDownList1.Text;
            Page.Theme = "Blue";// Blue is The theme Name


step 3:in SelectedIndexChanged event use coding as

for dropdown 1 use as:

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        Session["theme"] = DropDownList1.Text;


for dropdown 2 use as:

protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
         Session["theme"] = DropDownList1.Text;

now run it

based on changing the drop down the color is being changed dynamically


 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend