Reply
ASP.Net / Table / CSS Question
Old 10-26-2007, 01:12 PM ASP.Net / Table / CSS Question
Silent77's Avatar
Ultra Talker

Posts: 254
Name: Silent
Location: Ohio
I am trying to apply some css hover effects to the code below...
Code:
Dim Table AsNew HtmlControls.HtmlTable
Dim Desc1 AsNew Label
Dim tdcDesc1 AsNew HtmlControls.HtmlTableCell
Dim tbrRow1 AsNew HtmlControls.HtmlTableRow
 
With Desc1
.Text = "Description1"
.Style.Add("color", "#666666")
EndWith
 
With tdcDesc1
.Controls.Add(Desc1)
EndWith
 
With tbrRow1
With .Cells
.Add(tdcDesc1)
EndWith
EndWith
 
With Table
With .Rows
.Add(tbrRow1)
EndWith
.CellPadding = "1"
.CellSpacing = "1"
.Border = "1"
EndWith
 
PlaceHolder1.Controls.Add(Table)
I am trying to add a css hover to the table background... how would I add a name to this table that is accessible from the external CSS page? Thanks
__________________
Firefox
rediscover the web
Get Firefox today it's free! Down with internet explorer!
Silent77 is offline
Reply With Quote
View Public Profile Visit Silent77's homepage!
 
When You Register, These Ads Go Away!
     
Old 10-26-2007, 01:23 PM Re: ASP.Net / Table / CSS Question
Learning Newbie's Avatar
Moderator

Latest Blog Post:
What Does This Look Like?
Posts: 4,744
Name: John Alexander
First, with blocks suck - don't use them. Bad coding style. The same goes for html tables when you're displaying anything but tabular data.

Next, let's ditch the .Style.Add and instead give it a CSS class. There's even a property for most if not all ASP.NET server controls called CssClass, you would just assign that. In your CSS file, put :hover after the name of the class and add the styles there. That's in addition to the normal definition, not replacing it.
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 10-26-2007, 02:00 PM Re: ASP.Net / Table / CSS Question
Silent77's Avatar
Ultra Talker

Posts: 254
Name: Silent
Location: Ohio
I redid the code to something like this...

ASP Code Behind:
Code:
Dim Table AsNew HtmlControls.HtmlTable
Dim Desc1 AsNew Label
Dim Desc2 AsNew Label
Dim tdcDesc1 AsNew HtmlControls.HtmlTableCell
Dim tdcDesc2 AsNew HtmlControls.HtmlTableCell
Dim tbrRow1 AsNew HtmlControls.HtmlTableRow
With Desc1
.Text = "Description1"
EndWith
With Desc2
.Text = "Description2"
EndWith
With tdcDesc1
.Controls.Add(Desc1)
.ID = "TestingID"
EndWith
With tdcDesc2
.Controls.Add(Desc2)
EndWith
With tbrRow1
With .Cells
.Add(tdcDesc1)
.Add(tdcDesc2)
EndWith
EndWith
With Table
With .Rows
.Add(tbrRow1)
EndWith
.CellPadding = "1"
.CellSpacing = "1"
.Border = "1"
EndWith
ASP:
Code:
<tableid="Table"class="table1"runat="server">

</table>
CSS:
Code:
#table1.td
{
background-color:#0000FF;
}
So the question is why is the css not being applied to that table?
__________________
Firefox
rediscover the web
Get Firefox today it's free! Down with internet explorer!
Silent77 is offline
Reply With Quote
View Public Profile Visit Silent77's homepage!
 
Old 10-26-2007, 02:34 PM Re: ASP.Net / Table / CSS Question
Learning Newbie's Avatar
Moderator

Latest Blog Post:
What Does This Look Like?
Posts: 4,744
Name: John Alexander
Try a space between table1 and .td? As well you need a space between <table and id= I'm not sure if that's just the way the code is being displayed here?
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 10-26-2007, 06:37 PM Re: ASP.Net / Table / CSS Question
Silent77's Avatar
Ultra Talker

Posts: 254
Name: Silent
Location: Ohio
Nope still not working... I have no idea why.
__________________
Firefox
rediscover the web
Get Firefox today it's free! Down with internet explorer!
Silent77 is offline
Reply With Quote
View Public Profile Visit Silent77's homepage!
 
Old 10-29-2007, 05:23 PM Re: ASP.Net / Table / CSS Question
Learning Newbie's Avatar
Moderator

Latest Blog Post:
What Does This Look Like?
Posts: 4,744
Name: John Alexander
I can only assume you're using FireFox. Get Firebug, right click and select "Inspect Element". Over on the right you'll see everything about what CSS the browser is applying.
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ASP.Net / Table / CSS Question
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14839 seconds with 13 queries