ASP.NET - How to change body background color - Asked By saranya on 21-Feb-12 06:20 AM

Hi frndz!

Iam doing project in 2.0,c#. in my project i have to change body background color dynamically . The client can able to change any color as per their need in the website. How can i do? give code and detail explanation about that frndz
Somesh Yadav replied to saranya on 21-Feb-12 06:32 AM

Go to App_Themes folder , and change  the body styles insdide  clubsite.css  

this is what you will find for the body ,

-family: Tahoma, Verdana, Helvetica, Helvetica-Narrow, sans-serif;
: 0px;
: #FED36B url(images/background_main.jpg) repeat-y center top;
-size: 0.7em;


you can also set the body styles inline , in masterpage file

<body style=" background-color:#ccc; ">

Venkat K replied to saranya on 21-Feb-12 06:34 AM
You need to understand the Themes concepts for this, You should have multiple style sheets which should be loaded dynamically based on the color selecdtion.

How it works...
Check this link:

Web Star replied to saranya on 21-Feb-12 06:47 AM
When you need to change background color dynamically then best way is you can put id of the body control and change it with help of differnt CSS.
You write different background color css and than change by using id at runtime based on your condition

hope this helps you
dipa ahuja replied to saranya on 21-Feb-12 08:21 AM
There is a concept in called theme. you have to implement themes

You can implement thems by adding new .skin file in your website:
1. Add one skin file in your website:
2. It will ask you to add in App_Themes folder say yes
3. Add the code in your skin file
Just for beginning add the code :
<asp:button runat="server" BackColor="lightblue" ForeColor="black" />
and save it.
Now in you webpage in Page Directive add the Theme property = skinfile ex:
<%@ Page Theme="SkinFile" Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
Add one button in your webpage. And Run the page. You will get the effect of button as you have provided in the theme file
Same way you can apply theme to any webpage , and can crete themes of any Server Controls:
you will get so many articles on themes by googling
hope this will help you