can I add a style to RadioButtonList?

K

Kevin Blount

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
 
G

Gaurav Vaish \(www.EdujiniOnline.com\)

<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
-----------------------------------------
 
K

Kevin Blount

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 said:
most likely there is a problem in your css code



Kevin Blount said:
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
 
K

Kevin Blount

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
 
C

clintonG

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
 
J

Jon Paal

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 said:
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 said:
most likely there is a problem in your css code



Kevin Blount said:
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
 

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

Top