can I add a style to RadioButtonList?

Discussion in 'ASP .Net' started by Kevin Blount, Oct 9, 2006.

  1. Kevin Blount

    Kevin Blount Guest

    Here's the C# code I'm trying to add:

    <%
    listitem1.Text = commIndexText["tx_3"].ToString(); listitem2.Text =
    commIndexText["tx_8"].ToString();
    listitem3.Text = commIndexText["tx_9"].ToString();
    %>
    <asp:RadioButtonList CssClass="smallFont" ID="login_details"
    runat="server" TextAlign="right">
    <asp:ListItem ID="listitem1" Value=1 ></asp:ListItem>
    <asp:ListItem ID="listitem2" Value=2 ></asp:ListItem>
    <asp:ListItem ID="listitem3" Value=3 ></asp:ListItem>
    </asp:RadioButtonList>

    the three .Text lines at the top get text from a database and put it in
    place, which works fine

    The RadioButtonList specifies the CssClass as "smallFont", which is
    Tahoma 8pt, but this isn't applied to the text I add to my ListItems.

    Can anyone help me understand why?

    TIA

    Kevin
     
    Kevin Blount, Oct 9, 2006
    #1
    1. Advertising

  2. > <asp:RadioButtonList CssClass="smallFont" ID="login_details"
    > runat="server" TextAlign="right">


    > The RadioButtonList specifies the CssClass as "smallFont", which is Tahoma
    > 8pt, but this isn't applied to the text I add to my ListItems.


    Because the CSS-Class is only for the table generated.

    You will need to have CSS-Class for each ListItem that you add... I'm
    afraid, there's no other way out (AFAIK).


    --
    Happy Hacking,
    Gaurav Vaish | www.mastergaurav.com
    www.edujinionline.com
    http://eduzine.edujinionline.com
    -----------------------------------------
     
    Gaurav Vaish \(www.EdujiniOnline.com\), Oct 10, 2006
    #2
    1. Advertising

  3. Kevin Blount

    Jon Paal Guest

    most likely there is a problem in your css code



    "Kevin Blount" <> wrote in message news:...
    > Here's the C# code I'm trying to add:
    >
    > <%
    > listitem1.Text = commIndexText["tx_3"].ToString(); listitem2.Text = commIndexText["tx_8"].ToString();
    > listitem3.Text = commIndexText["tx_9"].ToString();
    > %>
    > <asp:RadioButtonList CssClass="smallFont" ID="login_details" runat="server" TextAlign="right">
    > <asp:ListItem ID="listitem1" Value=1 ></asp:ListItem>
    > <asp:ListItem ID="listitem2" Value=2 ></asp:ListItem>
    > <asp:ListItem ID="listitem3" Value=3 ></asp:ListItem>
    > </asp:RadioButtonList>
    >
    > the three .Text lines at the top get text from a database and put it in place, which works fine
    >
    > The RadioButtonList specifies the CssClass as "smallFont", which is Tahoma 8pt, but this isn't applied to the text I add to my
    > ListItems.
    >
    > Can anyone help me understand why?
    >
    > TIA
    >
    > Kevin
     
    Jon Paal, Oct 10, 2006
    #3
  4. Kevin Blount

    Kevin Blount Guest

    Possibly, but that class works perfectly on all other elements, and if I
    apply it manually it works too, i.e.

    listitem1.Text = "<span class='smallFont'>" +
    commIndexText["tx_3"].ToString() + "</font>";

    It also works on other .NET form controls, such as <asp:TextBox>



    Jon Paal wrote:
    > most likely there is a problem in your css code
    >
    >
    >
    > "Kevin Blount" <> wrote in message news:...
    >> Here's the C# code I'm trying to add:
    >>
    >> <%
    >> listitem1.Text = commIndexText["tx_3"].ToString(); listitem2.Text = commIndexText["tx_8"].ToString();
    >> listitem3.Text = commIndexText["tx_9"].ToString();
    >> %>
    >> <asp:RadioButtonList CssClass="smallFont" ID="login_details" runat="server" TextAlign="right">
    >> <asp:ListItem ID="listitem1" Value=1 ></asp:ListItem>
    >> <asp:ListItem ID="listitem2" Value=2 ></asp:ListItem>
    >> <asp:ListItem ID="listitem3" Value=3 ></asp:ListItem>
    >> </asp:RadioButtonList>
    >>
    >> the three .Text lines at the top get text from a database and put it in place, which works fine
    >>
    >> The RadioButtonList specifies the CssClass as "smallFont", which is Tahoma 8pt, but this isn't applied to the text I add to my
    >> ListItems.
    >>
    >> Can anyone help me understand why?
    >>
    >> TIA
    >>
    >> Kevin

    >
    >
     
    Kevin Blount, Oct 10, 2006
    #4
  5. Kevin Blount

    Kevin Blount Guest

    Thanks for the reply, Gaurav.

    I think I tried adding the style to the ListItem as well, with no luck.
    I'll revert to adding <span class=> when adding the listitem.Text; it's
    dirty, but it works :)

    Kevin


    Gaurav Vaish (www.EdujiniOnline.com) wrote:
    >> <asp:RadioButtonList CssClass="smallFont" ID="login_details"
    >> runat="server" TextAlign="right">

    >
    >> The RadioButtonList specifies the CssClass as "smallFont", which is Tahoma
    >> 8pt, but this isn't applied to the text I add to my ListItems.

    >
    > Because the CSS-Class is only for the table generated.
    >
    > You will need to have CSS-Class for each ListItem that you add... I'm
    > afraid, there's no other way out (AFAIK).
    >
    >
     
    Kevin Blount, Oct 10, 2006
    #5
  6. Kevin Blount

    clintonG Guest

    This hack can be used to style list items...
    <asp:ListItem Value="Sunday" Text="<span class='className'>Sunday</span>" />

    But my hack as noted above doesn't work for removing colored background the
    POS IE applies to checkboxes and radio buttons.

    Does anybody know how to get rid of the colored background? This bug showed
    up a long long time ago and at one time I had and used the hack to
    work-around the POS IE but I've forgotten the hack and don't seem to have a
    copy of the hack in my snippets collection.


    <%= Clinton Gallagher
    NET csgallagher AT metromilwaukee.com
    URL http://clintongallagher.metromilwaukee.com/
    MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W



    "Kevin Blount" <> wrote in message
    news:...
    > Here's the C# code I'm trying to add:
    >
    > <%
    > listitem1.Text = commIndexText["tx_3"].ToString(); listitem2.Text =
    > commIndexText["tx_8"].ToString();
    > listitem3.Text = commIndexText["tx_9"].ToString();
    > %>
    > <asp:RadioButtonList CssClass="smallFont" ID="login_details"
    > runat="server" TextAlign="right">
    > <asp:ListItem ID="listitem1" Value=1 ></asp:ListItem>
    > <asp:ListItem ID="listitem2" Value=2 ></asp:ListItem>
    > <asp:ListItem ID="listitem3" Value=3 ></asp:ListItem>
    > </asp:RadioButtonList>
    >
    > the three .Text lines at the top get text from a database and put it in
    > place, which works fine
    >
    > The RadioButtonList specifies the CssClass as "smallFont", which is Tahoma
    > 8pt, but this isn't applied to the text I add to my ListItems.
    >
    > Can anyone help me understand why?
    >
    > TIA
    >
    > Kevin
     
    clintonG, Oct 10, 2006
    #6
  7. Kevin Blount

    Jon Paal Guest

    could be a case problem.

    try renaming the attribute to :

    cssClass="smallFont"

    also make sure the case of the name matches the css file case


    "Kevin Blount" <> wrote in message news:...
    > Possibly, but that class works perfectly on all other elements, and if I apply it manually it works too, i.e.
    >
    > listitem1.Text = "<span class='smallFont'>" + commIndexText["tx_3"].ToString() + "</font>";
    >
    > It also works on other .NET form controls, such as <asp:TextBox>
    >
    >
    >
    > Jon Paal wrote:
    >> most likely there is a problem in your css code
    >>
    >>
    >>
    >> "Kevin Blount" <> wrote in message news:...
    >>> Here's the C# code I'm trying to add:
    >>>
    >>> <%
    >>> listitem1.Text = commIndexText["tx_3"].ToString(); listitem2.Text = commIndexText["tx_8"].ToString();
    >>> listitem3.Text = commIndexText["tx_9"].ToString();
    >>> %>
    >>> <asp:RadioButtonList CssClass="smallFont" ID="login_details" runat="server" TextAlign="right">
    >>> <asp:ListItem ID="listitem1" Value=1 ></asp:ListItem>
    >>> <asp:ListItem ID="listitem2" Value=2 ></asp:ListItem>
    >>> <asp:ListItem ID="listitem3" Value=3 ></asp:ListItem>
    >>> </asp:RadioButtonList>
    >>>
    >>> the three .Text lines at the top get text from a database and put it in place, which works fine
    >>>
    >>> The RadioButtonList specifies the CssClass as "smallFont", which is Tahoma 8pt, but this isn't applied to the text I add to my
    >>> ListItems.
    >>>
    >>> Can anyone help me understand why?
    >>>
    >>> TIA
    >>>
    >>> Kevin

    >>
     
    Jon Paal, Oct 12, 2006
    #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. ani
    Replies:
    0
    Views:
    489
  2. Karl
    Replies:
    0
    Views:
    812
  3. Ryan Taylor
    Replies:
    2
    Views:
    14,669
    maclade
    Mar 20, 2008
  4. lb
    Replies:
    1
    Views:
    455
  5. Ken Varn
    Replies:
    0
    Views:
    531
    Ken Varn
    Apr 26, 2004
Loading...

Share This Page