Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8103195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:28:25+00:00 2026-06-05T23:28:25+00:00

I am trying to add style to a table row in C# code. However,

  • 0

I am trying to add style to a table row in C# code. However, as simple as it may seem, I caanot find the proper way to do it. The code for my table is

<table width="100%" style="vertical-align:top; height:170px;" border="0" cellspacing="0" cellpadding="0"> 

    <tr id="trTasks" runat="server" onmouseover="this.bgColor='#eaeaea';" onmouseout="this.bgColor='#FFFFFF';" bgcolor="#FFFFFF"/>

</table>

I would like to set a different background color for trTasks when a condition is fullfiled. I’ve tried doing it like this:

trCompletedTasks.Attributes.Add("CssClass", "SelectedItem");

and

trCompletedTasks.Style.Add("CssClass", "SelectedItem");

but none of these seems to work.

Any suggestions would be much appreciated. Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:28:26+00:00Added an answer on June 5, 2026 at 11:28 pm

    The HTML attribute is named class:

    trCompletedTasks.Attributes.Add("class", "SelectedItem");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add a border and padding to the table row of
I am trying to add a new row in a table via javascript. I
I am trying to fix height for HTML table row. Below is the code
I'm trying to add a row to a table and have that row slide
I'm trying to add a table row with ajax/jquery that has a form element
I'm trying to add musical style columns to an event table and from what
I'm trying to add a formatter to my Automapper configuration to style all DateTime?
Trying to add email notification to my app in the cleanest way possible. When
I'm trying to use jQuery to add dynamic Add/Remove row function, but I meet
I'm trying to add some additional lines to a table in FOP, to fill

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.