Creating a table cell and changing the color on hover.

  • Thread starter Thread starter Mufasa
  • Start date Start date
M

Mufasa

I need to create a table dynamically do I'm using the asp:table with rows
and cells. All works fine. But I'd like to have it so that when a person
hovers over the cell the background color changes.

Here's the code I'm doing and it doesn't seem to do anything on the
mouseover:


TableRow lRow = new TableRow();
TableCell lCell = new TableCell();

lCell.Attributes.Add("onmouseover",
@"this.style.backgroundcolor='blue';");
lCell.BackColor = System.Drawing.Color.FromArgb(0x9A6B37);
lCell.ForeColor = System.Drawing.Color.White;
lCell.Text = "This is a test";

lRow.Cells.Add(lCell);
tblMasterMenu.Rows.Add(lRow);


Any suggestions?

TIA - Jeff.
 
I need to create a table dynamically do I'm using the asp:table with rows
and cells. All works fine. But I'd like to have it so that when a person
hovers over the cell the background color changes.

Here's the code I'm doing and it doesn't seem to do anything on the
mouseover:

            TableRow lRow = new TableRow();
            TableCell lCell = new TableCell();

            lCell.Attributes.Add("onmouseover",
@"this.style.backgroundcolor='blue';");
            lCell.BackColor = System.Drawing.Color.FromArgb(0x9A6B37);
            lCell.ForeColor = System.Drawing.Color.White;
            lCell.Text = "This is a test";

            lRow.Cells.Add(lCell);
            tblMasterMenu.Rows.Add(lRow);

Any suggestions?

TIA - Jeff.

The property name is case sensitive, use backgroundColor instead.

Alexey Smirnov, [MVP]
 
Thanks. That worked great.

I need to create a table dynamically do I'm using the asp:table with rows
and cells. All works fine. But I'd like to have it so that when a person
hovers over the cell the background color changes.

Here's the code I'm doing and it doesn't seem to do anything on the
mouseover:

TableRow lRow = new TableRow();
TableCell lCell = new TableCell();

lCell.Attributes.Add("onmouseover",
@"this.style.backgroundcolor='blue';");
lCell.BackColor = System.Drawing.Color.FromArgb(0x9A6B37);
lCell.ForeColor = System.Drawing.Color.White;
lCell.Text = "This is a test";

lRow.Cells.Add(lCell);
tblMasterMenu.Rows.Add(lRow);

Any suggestions?

TIA - Jeff.

The property name is case sensitive, use backgroundColor instead.

Alexey Smirnov, [MVP]
 
Back
Top