Changing the CssClass for a <TD>

Discussion in 'ASP .Net' started by Larry Bud, Jan 4, 2007.

  1. Larry Bud

    Larry Bud Guest

    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...
     
    Larry Bud, Jan 4, 2007
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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...
    >
     
    Eliyahu Goldin, Jan 4, 2007
    #2
    1. Advertising

  3. Larry Bud

    Karl Seguin Guest

    I think you need to do:

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

    Karl

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


    "Larry Bud" <> wrote in message
    news:...
    > 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...
    >
     
    Karl Seguin, Jan 4, 2007
    #3
  4. Larry Bud

    Larry Bud Guest

    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
    >
    >
    > "Larry Bud" <> wrote in message
    > news:...
    > > 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.

    > >
     
    Larry Bud, Jan 4, 2007
    #4
  5. 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" <> wrote in message
    news:...
    >
    > 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
    >>
    >>
    >> "Larry Bud" <> wrote in message
    >> news:...
    >> > 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 Goldin, Jan 4, 2007
    #5
  6. Larry Bud

    Larry Bud Guest

    >
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Larry Bud" <> wrote in message
    > news:...
    > >
    > > 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
    > >>
    > >>
    > >> "Larry Bud" <> wrote in message
    > >> news:...
    > >> > 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 Goldin wrote:
    > 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.
     
    Larry Bud, Jan 4, 2007
    #6
  7. Larry Bud

    Karl Seguin Guest

    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" <> wrote in message
    news:...
    > >
    >> --
    >> Eliyahu Goldin,
    >> Software Developer & Consultant
    >> Microsoft MVP [ASP.NET]
    >> http://msmvps.com/blogs/egoldin
    >> http://usableasp.net
    >>
    >>
    >> "Larry Bud" <> wrote in message
    >> news:...
    >> >
    >> > 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
    >> >>
    >> >>
    >> >> "Larry Bud" <> wrote in message
    >> >> news:...
    >> >> > 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 Goldin wrote:
    >> 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.
    >
     
    Karl Seguin, Jan 4, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hardy Wang

    How to remove CssClass of a control?

    Hardy Wang, Nov 13, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    991
  2. Max
    Replies:
    1
    Views:
    2,015
  3. Mervin Williams

    Setting CSSClass property of Label control?

    Mervin Williams, Apr 6, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,522
    Scott
    Apr 6, 2004
  4. JezB

    CssClass attributes

    JezB, May 17, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    1,972
    Eliyahu Goldin
    May 17, 2004
  5. =?Utf-8?B?VmlkdWxh?=
    Replies:
    0
    Views:
    1,644
    =?Utf-8?B?VmlkdWxh?=
    Apr 27, 2006
Loading...

Share This Page