Solved

Asp table id and Css

Posted on 2014-01-25
5
558 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
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…

825 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