Connecting Tech Pros Worldwide Forums | Help | Site Map

Changing bgcolor in Master Page

Member
 
Join Date: Dec 2006
Posts: 39
#1: Sep 27 '08
Hi

I have a master page with <TD> columns defined in the table as <td bgcolor="#518643"> (which means bgcolor="green"). In one of my content pages, I have a dropdown with values such as blue, green. In that, if I select the value as blue, then all <TD>'s in Master page with bgcolor="#518643" should change as green. So that the use can customize their page according to their color selection.

Newbie
 
Join Date: Oct 2008
Posts: 8
#2: Oct 1 '08

re: Changing bgcolor in Master Page


Make a method in the master page class that receives a color and then changes the tds bgcolor (td probably must be runnat="server"). Then in the content page call that method of the masterpage.

void Page_Load(object sender, EventArgs e) //content page load event
{
Master.changeTDColor(Color);// changeTDColor is the method created in the master page.
}
insertAlias's Avatar
Forum Leader
 
Join Date: Apr 2008
Location: San Antonio, TX (USA)
Posts: 2,608
#3: Oct 1 '08

re: Changing bgcolor in Master Page


The problem is that what you set won't persist. You might be able to change it for one page load, but the next page you load, it will load the default master page. What you need to do is use cookies.

When a user selects a color, save that color to a cookie. And in your master page's Page_Load method, check for that cookie. If it exists, get the color from it and use it as the bgcolor (although using CSS is preferable now), otherwise, use a default color.
Reply