[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

accessing the class parameter of a HtmlTable

Posted on 2004-07-30
8
Medium Priority
?
316 Views
Last Modified: 2008-03-04
it's easy to manipulate the style param of a <td> within .net you just:

dividerCol1.Style.Clear();
dividerCol1.Style.Add("background-color","#CCCCCC");

or whatever

is there easy access to the css class param of a <td>? like <td class="backColor"> or do I have to go through the attributes property?
0
Comment
Question by:sethUSer420
[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
  • 6
  • 2
8 Comments
 
LVL 12

Expert Comment

by:AGBrown
ID: 11677406
Can you not just use dividerCol1.CssClass?
0
 
LVL 12

Expert Comment

by:AGBrown
ID: 11677420
Sorry, that was not meant to be flippant. I have been setting class attributes of various objects (including <tr> and <td>) using the cssclass property, admittedly that was through a datagrid.

Andy
0
 

Author Comment

by:sethUSer420
ID: 11677447
'System.Web.UI.HtmlControls.HtmlTableCell' does not contain a definition for 'CssClass'
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 12

Expert Comment

by:AGBrown
ID: 11677465
haha, I knew there would be a problem like that.

Andy
0
 

Author Comment

by:sethUSer420
ID: 11677488
haha

then dont waste my time with it
0
 
LVL 12

Expert Comment

by:AGBrown
ID: 11677610
For an HtmlControl run at the server, use

Dim tblc As System.Web.UI.HtmlControls.HtmlTableCell
Dim tblr As System.Web.UI.HtmlControls.HtmlTableRow
For Each tblr In Me.Table1.Rows
    tblr.Attributes.Add("class", "Row Class")
    For Each tblc In tblr.Cells
        tblc.Attributes.Add("class", "Cell Class")
    Next
Next
0
 
LVL 12

Expert Comment

by:AGBrown
ID: 11677680
or in c#, which your question was in

foreach (HtmlTableRow tblr in this.Table1.Rows)
{
      tblr.Attributes.Add("class", "row class");
      foreach (HtmlTableCell tblc in tblr.Cells)
      {
            tblc.Attributes.Add("class", "cell class");
      }
}
0
 
LVL 12

Accepted Solution

by:
AGBrown earned 750 total points
ID: 11678887
If you do this a lot, and you want more brevity in your code, you could always create a custom control inheriting a tablecell class. You could add your own myCssClass property to it, and then override the RenderAttrbutes method, adding the attributes at this stage from the properties that were set, and then calling the base RenderAttributes.

Might be more hassle than it is worth though. I suppose you could always use the WebControls (which have a cssclass property) instead of the HtmlControls, but there are probably advantages to using the HtmlControls in your situation which is why you haven't just gone for the WebControls in the first place.

Andy
0

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

649 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