?
Solved

Asp table id and Css

Posted on 2014-01-25
5
Medium Priority
?
623 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 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses
Course of the Month10 days, 17 hours left to enroll

770 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