Solved

Asp table id and Css

Posted on 2014-01-25
5
598 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 53

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 53

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

688 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