Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wrong background color

Status
Not open for further replies.

olypost

Programmer
Apr 15, 2005
43
US
I have the following script that is called in a checkbox control in a datagrid (did a attributes.add in the onitemdatabound event to 'assign' it to the checkbox).

Here's the javascript:
function colorRow(e)
{
if (!e) e = window.event;
var srcEl = e.target || e.srcElement;
var curElement = srcEl;
while (curElement && !(curElement.tagName == "TR"))
{  
// Keep going until we reach the parent table row
    curElement = curElement.parentNode;
}
  if (curElement != srcEl)
  {
if (srcEl.checked)
    {   
// Modify your colors here for a selected object
curElement.style.backgroundColor = "#fff8bb";
}
    else   
{
// Modify your colors for a deselected object (read: Normal)
curElement.style.backgroundColor = "#EDF5FF";
    }
      }
      }

Here's part of the itemdatabound:
Dim cb As CheckBox = CType(e.Item.FindControl("tbTimeCheck"), CheckBox)
cb.Attributes.Add("onClick", "javascript:colorRow(event)")


The checkbox works as intended. No problem. However, I have another linkbutton in the datagrid, that when clicked, ALWAYS sets the background color to a dark blue color. This color is what I has mistakenly inserted in the colorRow function at first, before I changed it. There is no reference in my form for this background color, anywhere!!!

Even if I comment out the itemdatabound code, the linkbutton STILL shows this dark blue color!! How could this be? Is it residing in memory or something?? I added new linkbutton to the datagrid and it does the same thing.

I even restored saved files from the day before, and STILL the dark blue color... Has anyone seen this before??

Thanks.
 
Try removing the "javascript:" from your onclick event - it's just not needed.

That aside, it sounds like a .Net problem (at least I assume you're designing this in .Net)... this being the case, I'd ask in that forum.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hmm - ignore that second suggestion for the moment - I've just re-read your post. Try clearing your browser cache... and if that fails, try a different browser.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Yes, using asp.net. Figured it out. For some reason, my itemcommand event stopped firing and it was rendering with my selected item colors (which I never realized I had!). I never saw these colors when the itemcommand worked....

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top