Solved

Asp table id and Css

Posted on 2014-01-25
5
548 Views
Last Modified: 2014-02-04
Hi,

 I am using asp Table with Id property.I have added some styles in css with table id.But style sheet not applying for that id .Remaining classes apply properly.

ASPX  :

                      <asp:Table ID="techtable" runat="server" CssClass="table table-bordered rating-table">
                 <asp:TableHeaderRow CssClass="text-center">
                    <asp:TableHeaderCell>Test1</asp:TableHeaderCell>
                    <asp:TableHeaderCell>Test2</asp:TableHeaderCell>
                    <asp:TableHeaderCell>test3</asp:TableHeaderCell>
                    <asp:TableHeaderCell>test4</asp:TableHeaderCell>
                    <asp:TableHeaderCell>test5</asp:TableHeaderCell>
                    <asp:TableHeaderCell>test6</asp:TableHeaderCell>
                </asp:TableHeaderRow>

             <asp:TableRow>
                <asp:TableCell>              </asp:TableCell>
            </asp:TableRow>                  

            </asp:Table>

like that 6 rows and 6 colums are present

CSS:

#techtable tbody tr:nth-child(6n),#techtable tbody tr:nth-child(6n-1),#techtable tbody tr:nth-child(6n-2){ background:#FFFFFF;}
#techtable tbody tr:nth-child(6n-3),#techtable tbody tr:nth-child(6n-4),#techtable tbody tr:nth-child(6n-5){ background:#F9F9F9;}


I have written css using id property but this id property not applying

tectable - id

Can u plz check and correct me?
0
Comment
Question by:mannevenu26
5 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39809783
It is best to look at rendered code when digging into css.  I have recreated your table and your code works fine.  

Both FFFFFF and F9F9F9 are essentially white http://www.color-hex.com/color/f9f9f9.

In my sample I gave the body a grey background and changed f9f9f9 to red so you can see it does work.   What result are you expecting?
http://jsbin.com/opohUVE/1/edit
<!DOCTYPE html>
<html>
<head>
  <style>
    
    body{background-color:grey;}
    
#techtable tbody tr:nth-child(6n),#techtable tbody tr:nth-child(6n-1),#techtable tbody tr:nth-child(6n-2){ background:#FFFFFF;}
    
#techtable tbody tr:nth-child(6n-3),#techtable tbody tr:nth-child(6n-4),#techtable tbody tr:nth-child(6n-5){ background:red;}
    
  </style>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <table id="techtable" class="table table-bordered rating-table">
    <thead>
      <tr><th>Test1</th></tr>
      <tr><th>Test2</th></tr>
      <tr><th>Test3</th></tr>
      <tr><th>Test4</th></tr>
      <tr><th>Test5</th></tr>
      <tr><th>Test6</th></tr>
      
    </thead>
    <tbody>
      <tr><td>body1</td></tr>
       <tr><td>body2</td></tr>
       <tr><td>body3</td></tr>
       <tr><td>body4</td></tr>
       <tr><td>body5</td></tr>
       <tr><td>body6</td></tr>
    </tbody>
  </table>
</body>
</html>

Open in new window

0
 

Author Comment

by:mannevenu26
ID: 39809952
This is working fine in html table.But if i use asp table it is not working,
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39810027
Can you post a link to your page so we can see how it renders.  If it is not currently in a public area, then just create one.
0
 
LVL 43

Expert Comment

by:Chris Stanyon
ID: 39810227
Double check the rendered source of your page, and make sure the TBODY tags are being included - they're optional so not actually needed for valid HTML - don't know whether the ASP code creates it or not - if not, then you'll need to change your CSS (drop the tbody bit)
0
 
LVL 18

Accepted Solution

by:
bruno earned 500 total points
ID: 39819855
the ID used in the <asp:table> tag is not what will be output in the rendered HTML. That's the ID used in .NET.

Easiest option for you is to also include "techtable" in your CssClass list and change your css to make that a class as well.

<asp:Table ID="techtable" runat="server" CssClass="table table-bordered rating-table techtable">

Open in new window


.techtable tbody tr:nth-child(6n),.techtable tbody tr:nth-child(6n-1),.techtable tbody tr:nth-child(6n-2){ background:#FFFFFF;}
.techtable tbody tr:nth-child(6n-3),.techtable tbody tr:nth-child(6n-4),.techtable tbody tr:nth-child(6n-5){ background:#F9F9F9;}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now