Creating a table cell and changing the color on hover.

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.
 
G

Guest

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.

Anon User, [MVP]
 
M

Mufasa

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.

Anon User, [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top