Changing the CssClass for a <TD>

L

Larry Bud

Can it be done?

I have a table, and in the <TD> I have <Td runat="server" id="mycell"
class="myclass"></td>

In the code behind, I can access mycell.style, but there is no
mycell.CssClass...
 
K

Karl Seguin

I think you need to do:

mycell.Attributes.Add("class", "somethingElse");

Karl
 
L

Larry Bud

Eliyahu said:
There is mycell.Attributes["class"]. Is it what you are after?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Larry Bud said:
Can it be done?

I have a table, and in the <TD> I have <Td runat="server" id="mycell"
class="myclass"></td>

In the code behind, I can access mycell.style, but there is no
mycell.CssClass...

That's it. Seems odd that I can't refer to CssClass like with other
elements.
 
E

Eliyahu Goldin

The reason is because CssClass is a property of the WebControl class whereas
<td runat=server...> makes an instance of the HtmlTableCell class which is a
descendant of the HtmlControl as opposed to WebControl.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Larry Bud said:
Eliyahu said:
There is mycell.Attributes["class"]. Is it what you are after?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Larry Bud said:
Can it be done?

I have a table, and in the <TD> I have <Td runat="server" id="mycell"
class="myclass"></td>

In the code behind, I can access mycell.style, but there is no
mycell.CssClass...

That's it. Seems odd that I can't refer to CssClass like with other
elements.
 
L

Larry Bud

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Larry Bud said:
Eliyahu said:
There is mycell.Attributes["class"]. Is it what you are after?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Can it be done?

I have a table, and in the <TD> I have <Td runat="server" id="mycell"
class="myclass"></td>

In the code behind, I can access mycell.style, but there is no
mycell.CssClass...

That's it. Seems odd that I can't refer to CssClass like with other
elements.
Eliyahu said:
The reason is because CssClass is a property of the WebControl class whereas
<td runat=server...> makes an instance of the HtmlTableCell class which is a
descendant of the HtmlControl as opposed to WebControl.


Then you would think I would have access to the .Class property,
similar to the way I have access to the .BgColor and .Style properties
of the cell.
 
K

Karl Seguin

I agree...Except Class is a reserved keyword in most languages...none the
less, there are some additional core attributes which should be exposed.

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/


Larry Bud said:
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Larry Bud said:
Eliyahu Goldin wrote:
There is mycell.Attributes["class"]. Is it what you are after?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Can it be done?

I have a table, and in the <TD> I have <Td runat="server"
id="mycell"
class="myclass"></td>

In the code behind, I can access mycell.style, but there is no
mycell.CssClass...

That's it. Seems odd that I can't refer to CssClass like with other
elements.
Eliyahu said:
The reason is because CssClass is a property of the WebControl class
whereas
<td runat=server...> makes an instance of the HtmlTableCell class which
is a
descendant of the HtmlControl as opposed to WebControl.


Then you would think I would have access to the .Class property,
similar to the way I have access to the .BgColor and .Style properties
of the cell.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top