Solved

Asp table id and Css

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
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 a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

705 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

19 Experts available now in Live!

Get 1:1 Help Now