Creating a table cell and changing the color on hover.

Discussion in 'ASP .Net' started by Mufasa, Jul 3, 2008.

  1. Mufasa

    Mufasa 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.
     
    Mufasa, Jul 3, 2008
    #1
    1. Advertising

  2. On Jul 3, 6:34 pm, "Mufasa" <> wrote:
    > 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]
     
    Alexey Smirnov, Jul 3, 2008
    #2
    1. Advertising

  3. Mufasa

    Mufasa Guest

    Thanks. That worked great.

    "Alexey Smirnov" <> wrote in message
    news:...
    On Jul 3, 6:34 pm, "Mufasa" <> wrote:
    > 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]
     
    Mufasa, Jul 3, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer

    Change cell color when hover

    VB Programmer, Jun 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    3,822
    VB Programmer
    Jun 11, 2004
  2. Franck
    Replies:
    7
    Views:
    3,433
    Franck
    Oct 12, 2005
  3. Menu control and hover text color

    , Jul 10, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    343
    Alessandro Zifiglio
    Jul 12, 2006
  4. Kamaljeet Saini
    Replies:
    0
    Views:
    429
    Kamaljeet Saini
    Feb 13, 2009
  5. Arthur Shapiro
    Replies:
    29
    Views:
    327
    Arthur Shapiro
    Jan 2, 2005
Loading...

Share This Page